How to improve look and feel of JAVA swing GUI?

41,642

Solution 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.

Solution 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.

Solution 3

Substance is a very configurable and modern LAF:

https://github.com/kirill-grouchnikov/substance

Solution 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);
});
}

Solution 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:)

Share:
41,642

Related videos on Youtube

Mandar
Author by

Mandar

Updated on July 09, 2022

Comments

  • Mandar
    Mandar almost 2 years

    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...

    • Dani
      Dani about 14 years
      move to Silverlight :-) (it's a joke)
    • Mandar
      Mandar about 14 years
      Hi all your answers are very helpful. Now i got some food for my brain. I will try all these things and chose which ever looks better option ;). Thanks a lot !
  • Carl Smotricz
    Carl Smotricz about 14 years
    Probably the very simplest recommendation. With luck, it could be exactly what the OP wanted!
  • Michael Borgwardt
    Michael Borgwardt about 14 years
    Actually, I'd say that changing from the default Metal L&F to the system L&F would be much better for most customers.
  • extraneon
    extraneon about 14 years
    @Michael Borgwardt OK. I agree with you there. What I actually tried to say is that a boring GUI is not really a problem for most users, they actually like something standard.
  • Frederik Wordenskjold
    Frederik Wordenskjold about 14 years
    I think thats a fair statement. My experience is that the user gets scared when seeing a gui he's not familiar with. They need something they can relate to. Which also improves usability.
  • Mandar
    Mandar about 14 years
    hi frederik i tried this. its so nice thanks for your help. this was something i wanted.
  • qasimzee
    qasimzee over 12 years
    That is a great out of the box solution. Worked in first attempt. Can't stop myself to voteup
  • jpangamarca
    jpangamarca over 9 years
    Yes it does improve usability. In the Metal LaF the enter key doesn't execute a button action when it has the focus, while the native Windows LaF does, something a Windows user expects.