2013-10-27 46 views
0

我制作了一个带有20个JInternalFrame的JDesktopPane。然而,当我图标化所有的人,我不能滚动查看照片(从左至右)enter image description hereScrollable Iconified JInternalFrames

import javax.swing.*; 
import java.awt.*; 
class Untitled { 
    public static JDesktopPane desk; 
    public static JFrame f; 
    public static void main(String[] args) { 
     f = new JFrame(); 
     f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
     f.setVisible(true); 
     f.setSize(1000,1000); 
     desk = new JDesktopPane(); 
     f.add(desk); 
     f.setContentPane(desk); 
     f.setSize(1200,800); 
     f.setSize(1201,801); 
     for(int i = 0; i < 10; i++){ 
      JInternalFrame j = new JInternalFrame("test",true,true,true,true); 
      desk.add(j); 
      j.setVisible(true); 
      j.setSize(300,500); 
     } 
     for(int a = 0; a < 10; a++){ 
      JInternalFrame j = new JInternalFrame("test2",true,true,true,true); 
      desk.add(j); 
      j.setVisible(true); 
      j.setSize(300,500); 
     } 
    } 
} 

有什么办法,我可以,例如,图标化JInternalFrames成一个JScrollPane,让我可以滚动浏览它们?

回答

1

看起来像你使用的是Mac。在Windows中,图标在水平空间用完时会彼此重叠。尽管如果减小桌面宽度,Windows仍然存在问题。

无论如何,DesktopManager类负责此行为。 iconifyFrame()方法被调用。所以你需要提供一个自定义的DesktopManager实现。

也许你可以窃取Windows实现并将它用于Mac?

+1

这个相关的[示例](http://stackoverflow.com/a/9422246/230513)维护一个'List '可能提供一个起点。 – trashgod