• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

unable to set Decorations

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's move this to the Swing forum
 
Nick Kompas
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops sorry about that :roll:
 
Ranch Hand
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic