简体   繁体   English

当设置外观时,JOptionPane不起作用

[英]JOptionPane has no effect when look and feel set

I set below look and feel for main class. 我在下面为主要班级设置了外观。

Base class code: 基类代码:

 static
{
    try
    {
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    }
    catch (Exception exception)
    {
        logger.error("Error setting look and feel!", exception);
    }
}

Sub class code: 子类代码:

   int result = JOptionPane.showOptionDialog(panel,
            message,
            "",
            JOptionPane.YES_NO_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null,
            formattedOptions,
            formattedOptions[0]);

The windows look and feel is not get set as windows for JOptionPane rather it's showing java default look and feel. Windows外观没有设置为JOptionPane的窗口,而是显示了Java默认外观。

Could you please help me out? 你能帮我吗?

This is most likely timing related. 这很可能与计时有关。 Try setting laf using vm arg: 尝试使用vm arg设置laf:

-Dswing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM