How to change background color of JOptionPane?

前端 未结 5 718
走了就别回头了
走了就别回头了 2020-12-09 12:01

I have added JOptionPane to my application but I do not know how to change background color to white?

`int option = JOptionPane.showConfirmDialog(bcfiDownloa         


        
5条回答
  •  忘掉有多难
    2020-12-09 12:27

    UIManager.put("OptionPane.background", Color.WHITE); UIManager.getLookAndFeelDefaults().put("Panel.background", Color.WHITE);

    Put this code before you call your JOptionPane dialog like:

    UIManager.put("OptionPane.background", Color.decode("#3c6562"));
    UIManager.getLookAndFeelDefaults().put("Panel.background", Color.decode("#3c6562"));
        
    int input= JOptionPane.showConfirmDialog
    (
       null,
       "Close the programm?",
       "Exit",
       JOptionPane.YES_NO_OPTION
     );
    
     if(input == 0)
     {
        System.exit(0);
     }
    

提交回复
热议问题