• Post Reply Bookmark Topic Watch Topic
  • New Topic

unable to set Decorations  RSS feed

 
Nick Kompas
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone!

I have this seemingly impossible problem with setting the default look and feel decorations.
It seems that it has to be set from the main method to work, but if there's a class that extends JFrame is called from another class then the decoration will not be set.

For instance in pseudocode:

class A extends JFrame{
A() //Constructor
{
JFrame.setDefaultLookAndFeel(true);
}
main(){
new B();
}
}
//This works. Class A will have the right decoration. However class B is called within class A and therefore the decoration will not be set even though in class B I have tried almost everything. E.G

class B extends JFrame
B()
{
JFrame.setDefaultLookAndFeelDecorated(true);
OR
this.setDefaultLookAndFeelDecorated(true);
OR
setDefaultLookAndFeelDecorated(true);
SwingUtilities.updateComponentTreeUI(this);
}

It just doesn't do it.

I read in forum that the decoration has to be set within the main method or that extending the JFrame is slightly buggy. I was just wondering if this is a bug.

Any ideas?
Thank you in advance.
Nick
 
Joe Ess
Bartender
Posts: 9426
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's move this to the Swing forum
 
Nick Kompas
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops sorry about that :roll:
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in your example, setting decorated(true) in A's constructor should not work
for A if extending JFrame
e.g.

the above should not decorate 'A'

but if constructing a JFrame in A's constructor it should work
e.g.


in all cases, B seems to decorate OK

try this, and switch between the #1/#2 A/B classes

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!