Exception in the iconization of JInternalFrame with DefaultDesktopManager

人走茶凉 提交于 2019-12-12 22:11:21

问题


I am trying to use DefaultDesktopManager (or a sub-class of this) to control the moves out of JInternalFrames from a desktop panel. I can prevent that a frame is moved out of its desktop pane, however, when I minimize the internal frame I get:

 Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at javax.swing.RepaintManager.getVolatileOffscreenBuffer(RepaintManager.java:965)
    at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1398)
    at javax.swing.RepaintManager.paint(RepaintManager.java:1206)
    ...

The piece of code is the following:

JDesktopPan pane = new JDesktopPane();
pane.setDesktopManager(new DefaultDesktopManager());

If I don't use DefaultDesktopManager (that is to say, I comment the second line above), I can minimize an internal frame without an exception.

NOTE: This question raises from the answer of another Stackoverflow question:

Preventing JInternalFrame from being moved out of a JDesktopPane


回答1:


With Java 1.8.0, the issue only occurs for me when using Mac OS X. The issue goes away when the "Mac OS X" look and feel is not used. This code solved the problem for me:

try  
  { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); }
catch (Exception e)
  { e.printStackTrace(); }


来源:https://stackoverflow.com/questions/28774432/exception-in-the-iconization-of-jinternalframe-with-defaultdesktopmanager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!