Re: L&F gotcha
John B. Matthews wrote:
I get the same result: no change to the JFrame. I think this is the
expected result. The decorations of top-level containers such as JFrame
I fixed it, sort of, by throwing away the old frame after setting the
L&F, and making a new one.
For some reason, this code moves the frame down and to the right,
probably some typo I'm not seeing at the moment. But the code does use
the Vista L&F on all frames but the Metal one, and on Metal correct goes
back to the Metal L&F when you re-select it.
public void actionPerformed( ActionEvent e )
{
try
{
UIManager.setLookAndFeel( laf );
UiManagerDefaults.this.frame.setVisible( false );
UiManagerDefaults.this.frame.dispose();
UiManagerDefaults.this.frame = new JFrame( "UIManager
Defaults" );
UiManagerDefaults.this.frame.setDefaultCloseOperation(
JFrame.EXIT_ON_CLOSE );
System.err.println( UiManagerDefaults.this );
frame.add( UiManagerDefaults.this.getContentPane() );
frame.setJMenuBar( UiManagerDefaults.this.getMenuBar() );
frame.setLocationRelativeTo( null );
defaults.resetComponents();
JMenuItem mi = (JMenuItem) e.getSource();
JPopupMenu popup = (JPopupMenu) mi.getParent();
JRootPane rootPane = SwingUtilities.getRootPane( popup.
getInvoker() );
SwingUtilities.updateComponentTreeUI( rootPane );
frame.pack();
frame.setVisible( true );
} catch( Exception ex )
{
System.out.println( "Failed loading L&F: " + laf );
System.out.println( ex );
}
}
}