How to change background color of JOptionPane?

前端 未结 5 705
走了就别回头了
走了就别回头了 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:11

    By using the UIManager class

     import javax.swing.UIManager;
    
     UIManager UI=new UIManager();
     UI.put("OptionPane.background",new ColorUIResource(255,0,0));
     UI.put("Panel.background",new ColorUIResource(255,0,0));
    

    or

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

提交回复
热议问题