LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-30-2004, 09:07 AM   #1
dave bean
Member
 
Registered: Jun 2003
Location: UK
Distribution: Slackware 9.1
Posts: 136

Rep: Reputation: 15
(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 ?
 
Old 01-30-2004, 05:44 PM   #2
coolman0stress
Member
 
Registered: Jun 2003
Location: Toronto, Ontario, Canada
Posts: 288

Rep: Reputation: 30
Pass it the this reference of the JFrame class.

Code:
JOptionPane.showMessageDialog(this, "I am a message");
 
Old 01-31-2004, 10:49 AM   #3
dave bean
Member
 
Registered: Jun 2003
Location: UK
Distribution: Slackware 9.1
Posts: 136

Original Poster
Rep: Reputation: 15
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 . . . .
 
Old 01-31-2004, 11:39 AM   #4
synna
Member
 
Registered: Jan 2004
Posts: 40

Rep: Reputation: 15
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.
 
Old 01-31-2004, 02:49 PM   #5
dave bean
Member
 
Registered: Jun 2003
Location: UK
Distribution: Slackware 9.1
Posts: 136

Original Poster
Rep: Reputation: 15
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
 
Old 01-31-2004, 05:11 PM   #6
german
Member
 
Registered: Jul 2003
Location: Toronto, Canada
Distribution: Debian etch, Gentoo
Posts: 312

Rep: Reputation: 30
try calling SwingUtilities.updateComponentTreeUI(frame);
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Lost pane,issues when creating alias from the bash shell spoult Linux - Software 2 04-19-2005 06:22 AM
Cannot set the path for java jgoggel Programming 2 07-23-2004 06:31 AM
Java can't find package, but PATH set correctly (j2se1.4.0, java.util.regex package) Ethan Programming 5 02-06-2004 09:55 PM
Pane view in Knode??? rberry88 Linux - Software 1 09-05-2003 07:07 AM
SuSe Docs Pane in the Farse thom Linux - Distributions 7 09-08-2002 04:07 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration