aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JFrame decorations aren't working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFrame decorations aren Watch "JFrame decorations aren New topic
Author

JFrame decorations aren't working

Jeremy Tartaglia
Ranch Hand

Joined: Mar 11, 2004
Posts: 62
I'm trying to switch between UIs at run time. I switch the Look and Feel, and tell the system to update but for some (Windows, Motif, and a few downloaded UIs) the window decorations refuse to come up. Obviously, they don't have decorations, so is there a way to dynamically switch between the decorations in a UI and the decorations specified by the operating system?
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
I'm not sure if L&F applies to JFrames since they are actual operating system objects (complete with HANDLEs if you're familiar with good ol' Win32 API programming). Child elements such as JPanels, and JButtons and who knows what else shouldn't have any problems reflecting your changes.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
Jeremy Tartaglia
Ranch Hand

Joined: Mar 11, 2004
Posts: 62
Well, it must apply somehow, because Metal L&F will change the window decorations on a JFrame. A few others which I downloaded from Javootoo.com do the same: Compiere, Kunststoff, Metouia, Plastic, Plastic3D, and Tonic. But, all I can imagine is going on is that, when the JFrame gets the signal from the UIManager, it just performs a simple check and, if there aren't Window Decorations available, just skips over drawing them. I really don't want that, because then I lose the close box, the ability to minimize and maximize the window, and it just looks wrong. ^^
Jeremy Tartaglia
Ranch Hand

Joined: Mar 11, 2004
Posts: 62
Heh, well, I found -A- way to do it. Just make a new JFrame with the specifications you need, copy all the components over, and delete the current window. Messy, but it works. ^^
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

You can also call setUndecorated( false ) to return the native frame border to the frame. You also have to check and make sure the look and feel support by using the getSupportsWindowDecorations() method of the LookAndFeel class. Here's how I got it to work -


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JFrame decorations aren't working