Author | Message | Time |
---|---|---|
Blade | Ok, I知 learning java right now and I read that you always have at least two look and feel options for the GUI, the default(metal) and the native OS look. My question is how do I implement a look and feel for my GUI and can you change the look and feel at runtime? I've read the java docs and fond a few methods that looked as if they could change the look and feel but they either didn't work or gave me an exception when I tried using them(I知 probably using them wrong). Another question I have is are the look and feels only good for swing components or does it effect all GUI components? | March 18, 2005, 11:51 PM |
iago | I've never been able to change it. But 2 things: Swing in Java 5 (or 1.5, whatever) is MUCH nicer than 1.4. SWT is a commercial package that uses native gui stuff so it runs faster and looks exactly like it should. | March 20, 2005, 2:26 AM |
Blade | I fond what I was looking for. The javax.swing package contains a class called IUManager full of static methods that can be used to manipulate the look and feel of your app. You can use the static method setLookAndFeel() to set the look and feel and getSystemLookAndFeel() to return the argument to set the look and feel(if you want the standard OS look and feel). http://java.sun.com/docs/books/tutorial/uiswing/misc/plaf.html is a link to the sun documentation on setting the look and feels of your java app. [code] try{ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }catch(Exception ex){ ex.printStackTrace(); } [/code] | March 21, 2005, 4:05 AM |