2013-06-20 29 views
2

時,JOptionPane沒有效果我在主類中設置了下面的外觀。當外觀設置爲

基類代碼:

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

子類代碼:

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

窗戶的外觀和感覺是不會被置爲JOptionPane的窗口,而它的顯示java的默認外觀感覺。

你能幫我一下嗎?

+0

僅僅只爲JOptionPane的,其他部件都在正確的外觀,或不 –

+0

是所有其他組件都表現爲按設定的外觀和在主類的感覺。但JOPtion不是? – user1280096

+0

在調用JOptionPane之前,您是否設置了外觀和感覺**? – Bnrdo

回答

0

這很可能與時間有關。嘗試設置LAF使用VM ARG:

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