1 Replies - 260 Views - Last Post: 28 June 2019 - 03:59 AM Rate Topic: -----

#1 sprint   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 27-June 19

Set background color of JFrame without calling getContentPane()

Posted 27 June 2019 - 09:25 PM

Copying codes from Internet is easy but understanding it is not.
Here is the code that I can't figure out why.
```
getContentPane().setBackground(Color.BLUE);
getContentPane().setForeground(Color.RED);
setBackground(Color.GREEN);
```
When I comment the third line,nothing different to my application.Can anyone please explain
1)Why we need to have third line of code?
2)Any difference for setting the Background of the Content Pane and the Frame?
Thanks in advandced!

Is This A Good Question/Topic? 0
  • +

Replies To: Set background color of JFrame without calling getContentPane()

#2 NormR   User is offline

  • D.I.C Lover
  • member icon

Reputation: 780
  • View blog
  • Posts: 5,858
  • Joined: 25-December 13

Re: Set background color of JFrame without calling getContentPane()

Posted 28 June 2019 - 03:59 AM

Pass this to Google for lots of discussions:
getcontentpane() in java swing

Also see the tutorial: https://docs.oracle....tml#contentpane

This post has been edited by NormR: 28 June 2019 - 06:34 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1