0

I made a JDesktopPane with 20 JInternalFrames. However, when I iconify all of them, I can't scroll through them (left to right)enter image description here

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);
        }
    }
}

Is there any way I can, for example, iconify the JInternalFrames into a JScrollPane, so that I can scroll through them?

mkaminsky
  • 353
  • 2
  • 10

1 Answers1

1

Looks like you are using a Mac. In Windows the icons get layered on top of one another when they run out of horizontal space. Although Windows still has a problem if you decrease the width of the desktop.

Anyway the DesktopManager class is responsible for this behaviour. The iconifyFrame() method is invoked. So you would need to provide a custom DesktopManager implementation.

Maybe you can steal the Windows implementation and use it for the Mac as well?

camickr
  • 321,443
  • 19
  • 166
  • 288
  • 1
    This related [example](http://stackoverflow.com/a/9422246/230513) maintains a `List` that may offer a starting point. – trashgod Oct 27 '13 at 23:48