Search code examples
javawindowsswinguser-interfaceuimanager

Java Windows UIManager


I'm attempting to use the UIManager in java to make all my pop up GUIs and error GUIs use the same colors. The issue is I can't seem to change the button color when using the windows style, as well I can't manage to change the GUIs title bar.

enter image description here

Code: Its rather simple, I'm calling UIManager.getLookAndFeelDefaults().put("Button.background", buttonColor) anda few other UI changes. Nothing major...


Solution

  • If you are using JOptionPane,

    You an change the title using this format to use your own title.

    JOptionPane.showMessageDialog(null, "This is the message", "This is the title", JOptionPane.YES_NO_OPTION);

    To set back ground color of dialog-

    UIManager UI=new UIManager();
    UI.put("OptionPane.background", Color.white);
    UI.put("Panel.background", Color.white);
    JOptionPane.showMessageDialog(null,"Text","SetColor",JOptionPane.YES_NO_OPTION);
    

    For changing buttons in dialog or everything else, create your own JDialog and set the button characteristics which you want.