(java) set JOption Pane to nice look
hi,
I have set my frame to setDefaultLookandFeelDecorated(true) with this statement. Code:
JFrame.setDefaultLookandFeelDecorated(true); In the same class i have a JOptionPane and i want it to have the same style as the main frame. I know the first parameter in constructing the JOptionPane is the frame which handles its display but i dont know how to refer to JFrame which i have set to be lookandfeeldecorted. can anyone help please ? |
Pass it the this reference of the JFrame class.
Code:
JOptionPane.showMessageDialog(this, "I am a message"); |
Yes i expected that to work as well but it doesn't. And i tried
Code:
this.setDefaultLookAndFeelDecorated(true); |
I think you shoud try to make a custom look and feel(just by extending the one you are using), so every componant as the same decoration.
|
its a good suggestion synna, I think this is the way i will go. By looking into that though i have realisied that to set the look of JOptionPanes you just need to declare:
Code:
JDialog.setDefaultLookAndFeel(true); thanks |
try calling SwingUtilities.updateComponentTreeUI(frame);
|
All times are GMT -5. The time now is 07:40 AM. |