Search code examples
javaswingjbuttoncalculatorlook-and-feel

Change Default Buttons in Java to Make Them Look "Better"


I'm essentially trying to mimic the default windows xp simple calculator. When I change the background colours of the buttons in Java it makes them look very flat and "boring". I want to make the buttons look as close as possible to the buttons in the Windows XP calculator.

Here is an image comparing mine to WinXp's: calc example

Is there some kind of method I can use to change the style of the buttons much like you can do in Visual Basic to make the buttons almost pop more or look 3D like the Windows Xp Calculator.

The default buttons in Java are sort of what I'm looking for except there not white there more of a blue kind of colour in a gradient.

Is this possible, or am I stuck with ugly button?


Solution

  • Try setting the system look and feel at the beginning of the main method:

    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    

    This will load all Swing widgets with a native-ish look.

    If you are insterested in what you are actually doing with this command, Oracle has a nice tutorial regarding look and feels: http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html