I am working on an Java application, and I'm setting the LookAndFeel. Everything of the LAF I like except the default background color of the JButtons. What's the best way to set that (and other properties) after I set the look and feel? I don't want to have to create my own look and feel that extends it... would love to just be able to change it after the line I set the LAF...
Found it myself shortly afterwards.
UIManager.getDefaults().put("Button.background",new Color(0xFFFFFF));
Related
Right now I set the LaF like this: UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); It works fine and gives the look and feel I want to have. Sadly at some point in my code, I have to set some icons manually, because the automatical setting of those doesn't work properly (sets wrong icon). I currently have:
if (node.getAllowsChildren()) {
setIcon(UIManager.getIcon("FileView.directoryIcon"));
}else {
setIcon(UIManager.getIcon("FileView.fileIcon"));
}
but it doesn't use the LaF icons and I have no idea, on how to find the icons that look like the LaF. So my question is, is there an easy way to get lets say the LaF folder icon?
Design I currently get:
And the design I want to have:
Try using the UIDefaults class to get the values:
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
Icon icon = (Icon)defaults.get(...);
Check out UIManager Defaults. This Icons change when the LAF is changed.
I want to set web look and feel only for a JCombobox in NetBeans.
Image :
Generally speaking in Swing you can't set the look and feel for any specific component but for the whole set of them. See How to Set the Look and Feel.
On the other hand, WebLaF provides extensions for Swing components that have a custom "Look" on their own with no need to set the Look and Feel to WebLaF for the entire application. In this case, instead of using a JComboBox you can use WebComboBox which is an extension of the previous one. However this custom look is limited and some features such as font (size, weight and family), renderers, pop ups, etc. don't change and still the same of the configured look and feel. So I wouldn't suggest you to do this at all and keep consistency either by setting WebLaf as Look and Feel or by using standard Swing components.
Consider the pictures below (note WebList is broken with Nimbus):
MetalLookAndFeel
NimbusLookAndFeel
WindowsLookAndFeel
WebLookAndFeel
Just add this after you set whatever default Swing UI you want and then you will get the WebComboBoxUI for all JComboBoxes only.
UIManager.put("ComboBoxUI", "com.alee.laf.combobox.WebComboBoxUI");
I am using the Nimbus LAF on my application and I want to change all buttons foreground colors. I do this setting:
UIManager.put("Button.foreground", Color.WHITE);
But this is not working. Maybe it is because I should only use the primary and secondary Nimbus colors? Could anyone help me please?
Thanks a lot.
simple way
1) you can set Color once by put value to UIManager, then will be valid for whole (for example JLabel) instance
2) dynamically set and override UIManager repeatedly
most complex way
3) create own UIManager, for example by aephyr
EDIT:
< to avoiding to create own Painters /> maybe correct way could be use non_buggy and todays Custom Look and Feel
I'm fairly confident that I have done my research before coming to you for help, but it's possible I have overlooked something.
I'm writing a java UI using the Nimbus l-a-f. I wish to change the background colour of a JSpinner on state-change, ie, when either the up or down button is pressed the background colour of the textfield within the jspinner changes colour to signify that the value has been altered.
I am aware this is possible using OTHER lookandfeels but not as easy with Nimbus, eg:
((JSpinner.NumberEditor)jSpinner1.getEditor()).getTextField().setBackground(color.yellow);
I have also looked into actually changing the colour theme of the UI manager, but I only want to change the colour when an action occurs, not just overall by default.
here or here
Is this at all possible and where do I start?
Failing this, I was hoping to just change a button's colour:
jButton.setBackground(Color.yellow);
This is easy enough but since the default colour is a painted gradient, how do I change it back to that?
Really hope someone out there knows or can help.
Much appreciated in advance!
Yes, it is possible. See this example (i.e. SpinnerDemo4) from The Java Tutorials for more detail. And yes, I did set the LaF to Nimbus when testing the code therein.
Below UI is something I'd like to aim for. But I have no idea, how they have the "skin" of the app. On my end, the Java application looks like it was made in 1990s. I want to change a look to a more modern style.
What components are they using possibly here? JSplitpane for one. but I'm not sure how they created that "Dokument/Vorschau" tabs.
First using a look and feel like Nimbus, can easily change the look of your application to a have a more modern feel.
Second, you will need to customize the font, color, borders, node icons, etc. of each component type to achieve a non-standard look. Some of these can be changed with updates to the UIDefaults of the look and feel but many will be made by calling methods on the specific instance of the component you are dealing with.
Try a javax.swing.JTabbedPane.
If you really want to change the complete look-and-feel of your application from scratch, you should take a look at Synth L'n'F. You can define style and appearance of components and bind them to components which match certain criteria.
(My opinion on that matter: heavily themed apps usually look and feel out-of-the-place and only make it harder to use the app, so I'd actually try to avoid themeing)