LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   (java) set JOption Pane to nice look (https://www.linuxquestions.org/questions/programming-9/java-set-joption-pane-to-nice-look-140334/)

dave bean 01-30-2004 09:07 AM

(java) set JOption Pane to nice look
 
hi,
I have set my frame to setDefaultLookandFeelDecorated(true) with this statement.
Code:

JFrame.setDefaultLookandFeelDecorated(true);
this statement is in the main and the constructor calls the super() which is JFrame as i am extending JFrame.

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 ?

coolman0stress 01-30-2004 05:44 PM

Pass it the this reference of the JFrame class.

Code:

JOptionPane.showMessageDialog(this, "I am a message");

dave bean 01-31-2004 10:49 AM

Yes i expected that to work as well but it doesn't. And i tried

Code:

this.setDefaultLookAndFeelDecorated(true);
tellUser.setRootFrame(this);

it all compiles fine but the OptionPane is still showing the default look . . . .

synna 01-31-2004 11:39 AM

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.

dave bean 01-31-2004 02:49 PM

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);
and then you see the nice brown colour that Sun chose for warning messages. Its a good reason to extend the lookandfeel and create your own :)

thanks

german 01-31-2004 05:11 PM

try calling SwingUtilities.updateComponentTreeUI(frame);


All times are GMT -5. The time now is 07:40 AM.