|
Subject:
|
applying custom look and feel for GUI
|
|
Posted By:
|
wesleywj2
|
Post Date:
|
11/7/2003 10:00:00 AM
|
hello there,
as for the GUI and other stuff, how am i gonna set the L&F for the windows and buttons? as are there any L&F skin that can be downloaded and apply it to the application?
|
|
Reply By:
|
Martyn
|
Reply Date:
|
11/7/2003 11:06:24 AM
|
Use the following code snippet for a Windows look and feel:
javax.swing.UIManager.setLookAndFeel( "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" );
javax.swing.SwingUtilities.updateComponetTreeUI( this );
Cheers
Martyn
|
|
Reply By:
|
wesleywj2
|
Reply Date:
|
11/14/2003 5:32:16 PM
|
oh, thks for the reply.. but when I put it inside the extended class Jframe I wrote, which type of exception i should catch? and is it appropriate to include the code inside the constructor? or some other method's body?
thks..
|
|
Reply By:
|
Martyn
|
Reply Date:
|
11/15/2003 8:57:48 AM
|
The setLookAndFeel method can throw 4 differnt types of exception. You can catch each one of them individually, catch only the ones you are bothered about, or use Exception to catch them all. Personlly, I would just catch Exception.
It is fine to put the look & feel code into the constructor.
Cheers
Martyn
|
|
Reply By:
|
mrafaqi
|
Reply Date:
|
11/15/2003 10:02:43 PM
|
hi! i know only that there are three look and feel style, 1. java native look and feel 2. motif look and feel 3. window look and feel (System look and feel)
following is the code which is better if write in main() before creating the object of the class. i know just for two, as java native is default but to switch from one to another i do not know
but try this
public static void main(String args[]) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch(Exception exp) { System.out.println(exp); } }
above code is for window look and feel, to make motif look and feel just change the argument in setLookAndFeel which is a String argument "com.sun.java.swing.plaf.motif.MotifLookAndFeel"
now LookAndFeel will be motif
|