It's not a secret anymore!*
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFrame decorations aren Watch "JFrame decorations aren New topic

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.

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 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

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 -

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: JFrame decorations aren't working
Similar Threads
Switching between the frames
Problem with fullscreen
swing..simple Q?