I use UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); to set a LAF and it works fine. But this time I also implemented a tray and it looks ugly - like Motif. How can I set LAF for the tray?
The class you're probably using for this is java.awt.SystemTray.
The tray uses AWT, not Swing. You cant set the look and feel of it.
I think there is a duplicate of this somewhere on here.
Related
I made a simple Jframe with its child components in netbeans, when i run the application it shows it in NIMBUZZ lookandfeel as shown below:-
But I want it to be always shown in WINDOWS lookandfeel as shown below :-
How am I suppose to do that??
Before creating your first window call this code:
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
note that this will work as expected only under windows where this is the system LAF
You maybe looking for setWindowDecorationStyle(), although some L&Fs may not support the feature. A complete example is cited here.
Im building a GUI in Netbeans, it looks good in the designer but when I run the program it looks pretty rubbish. Im using a Mac and so I feel that it would look better using the Mac OS LAF but then when I run it on Windows, what will happen? Is a Windows system able to use the Mac LAF and vice-versa?
I dont usually mind the Ocean/Metal LAF but it looks better on Windows than it does on Mac, is there a way to set a theme as a fallback? Or to change depending on the system its running on?
The UIManager.setLookAndFeel(String className) Loads the LookAndFeel specified by the given class name:className, using the current thread's context class loader.
To set look and feel of your current system, make use of UIManager.getSystemLookAndFeelClassName(): Returns the name of the LookAndFeel class that implements the native system look and feel if there is one, otherwise the name of the default cross platform LookAndFeel class.
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
put this code before you create instance of your application window: JFrame or any such Top-level Container.
In my Java application I have a window which holds a JTextArea within a JScrollPane with scrollbars policies set to AS_NEEDED.
As I run my application I see that JTextArea this way:
Why am I seeing the scrollbars with that cutaway knob (which doesn't reflect a "standard" representation like this)?
The Layout for the frame is GridBagLayout, and I'm on Mac OS X 10.8.2, should that matter.
This is based on the Look and Feel your app is using, and the limitations of Java's integration with the native OS layout components. The one in your screenshot looks like Nimbus.
Swing applications always custom-render the look and feel, and don't do a very good job of using the native OS widgets everywhere. The result is that you get weird looks that might be consistent the OS only some of the time, or only with certain layout components.
Welcome to developing cross-platform desktop apps in Java. :(
To attempt to get the system look and feel when your application starts you can do this:
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassname());
} catch (Exception e) {
// Handle exception
}
This will set the look and feel to that of the system regardless of what you run it on.
And as mentioned, the default look and feel for your application appears to be Nimbus and not OSX's Aqua, which again can be fixed with he above snippet and you could (should you care to) offer a UI option to the user to change the look and feel of the application to whatever they chose.
You are with Nimbus LookAndFeel
http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/nimbus.html
I have a swing application. Below is a small screenshot.
OS: Win 7
What is irritating is the theme. I have tried several other screens but they all have such appearance. Eclipse and Netbeans for example have a much better UI. The FileChooser and Frame is general is much pleasing. How do I have such a theme.
Thanks.
Change the look and feel to the Windows one before creating anything UI-related in your program:
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
Looks like you are using the Metal Look and Feel. Try using some other look and feel that might interest you.
Refer http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html, for more information.
This will give you everything you want to know
http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
UIManager.getSystemLookAndFeelClassName() will give you the most appropriate for the OS it's running on
there is many look and feels packages like :
1)JTattoo
2)BlueLight
3)joxy
4)Nimrod
5)Oyoaha
6)TinyLaf
....etc
you have to read about previous types
been trying this for a while now and can't seem to get it to work. I wrote a little GUI app that uses the OS's default Look And Feel. While I wrote it on linux, it is mainly intended to be used on Windows. The JSliders under linux are fine by me, but on windows the thumbs(sliders? I don't know the right word) become very narrow, and they stop displaying the value above the thumb, too. I thought I could get around this problem with something like this:
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
UIManager.getLookAndFeelDefaults().put("Slider.thumbWidth", 20);
But, obviously, it doesn't work. How should I do this? seems like it should be a trivial thing, and I already spent more time on it than I'll ever want to admit.
thanks a lot
Not all LAFs will use the UIManager properties.
I'm not aware of the "thumbWidth" property. Maybe you meant to use the "trackWidth"?
Here is a complete list of the UIManager Defaults.