• Post Reply Bookmark Topic Watch Topic
  • New Topic

setDefaultLookAndFeel

 
Abigail Decan
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
setDefaultLookAndFeel is not working as i'm expecting.

this is my code:


after reading the oracle tutorial on how to make frames and reading FrameDemo2.java
http://docs.oracle.com/javase/tutorial/uiswing/examples/components/FrameDemo2Project/src/components/FrameDemo2.java
i thought setDefaultLookAndFeelDecorated(true); would give me a different decoration than the default windows 7 border.
but toggling between true and false changes nothing, and changing setUndecorated does nothing either.
what am i supposed to do to make it look like the one in theFrameDemo2 window?
 
Tony Docherty
Saloon Keeper
Posts: 3137
72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The API docs says "Provides a hint as to whether or not newly created JFrames should have their Window decorations (such as borders, widgets to close the window, title...) provided by the current look and feel...".
As you have already created your JFrame before you call the method it is having no effect. Try moving the call to the main method before you create your instance of C.
 
Abigail Decan
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here's my new code:



, which worked.
I re-read the code, and I noticed that it didn't apply the setDefaultLookAndFeel to an instance but used it
 
Rob Spoor
Sheriff
Posts: 20817
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is possible to change the look & feel after the GUI is already created using SwingUtilities.updateComponentTreeUI, but you should be careful with that. The new UI may cause components to be larger, messing up your layouts.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!