Is there a way to Change the JOptionPane layout, like the color at the top and the image at the top left?

后端 未结 2 470
臣服心动
臣服心动 2021-01-19 17:21

I am curious, I am wondering if there exist a way to make the top of the JOptionPane into a different color, say red or orange. Also i was wondering how to change the image

2条回答
  •  天涯浪人
    2021-01-19 17:52

    There are three options here:

    1. Use one of the predefined icons using the respective message type:
      JOptionPane.showMessageDialog(frame, "Eggs are not supposed to be green.", "Inane error", JOptionPane.ERROR_MESSAGE);

    2. Use a custom icon:
      JOptionPane.showMessageDialog(frame, "Eggs are not supposed to be green.", "Inane custom dialog", JOptionPane.INFORMATION_MESSAGE, icon);

    3. Use a look & feel to have consistent icons all over your application: How to Set the Look and Feel

    Have a look at this page of the Java Tutorial for more information on dialogs.

提交回复
热议问题