问题
I am working on a project that uses Java Swing. The default look and feel of the Java Swing GUI is very boring. Is there any way I can use a better look and feel? Something like on web pages...
回答1:
You can set the look and feel to reflect the platform:
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
If this is not nice enough for you, take a look at SWT for Eclipse.
回答2:
Look at the Java tutorial for setting the look and feel. In addition to those mentioned there, recent Java 6 releases also include the Nimbus Look and Feel.
回答3:
Substance is a very configurable and modern LAF:
https://github.com/kirill-grouchnikov/substance
回答4:
if you're good with Photo shop you could declare the JFrame as undecorated and create your own image that will server as your custom GUI.
in this example refer to the JFrame as frame.
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(800, 600);
//If you want full screen enter frame.setExtendedState(JFrame.MAXIMIZE_BOTH);
frame.setUndecorated(true);
now that the JFrame has its own border and custom GUI, if you defined your own custom buttons for minimize, maximize, and exit you need to lay a JPanel over the buttons and declare what those buttons will do in a action listener function(lol sorry...I don't know if it's called function like c++ or class...) for example we will refer to the JPanel as panel and we will set up a exit button.
panel.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e){
System.exit(JFrame.EXIT_ON_CLOSE);
});
}
回答5:
You can take a look here. I googled on java swing theme.
That said, if you're making a hobby project changing the LAF is no problem. If you're making software for your buddies it's also not a problem. If you make software for customers keep the swing default. It works well and isn't too exciting:)
回答6:
Another option is the Plastic Look-and-feel. It gives Swing apps an XP-like look and offers a lot of customization options.
EDIT: I just noticed that the images on that page are broken. If you click through to the JGoodies Looks page, you at least see 3 examples of what you can accomplish with those looks.
来源:https://stackoverflow.com/questions/2592207/how-to-improve-look-and-feel-of-java-swing-gui