Exception in the iconization of JInternalFrame wit

2019-07-20 07:58发布

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条回答
Emotional °昔
2楼-- · 2019-07-20 08:37

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(); }
查看更多
登录 后发表回答