0

I've got 4 JInternalFrames that I've added to a JDesktopPane which is then added to the content pane of a JRibbonFrame (I'm using the Flaming api). I add the JDesktopPand to the JRibbonFrame, set the JRibbonFrame to visible and then add the JInternalFrames to the JDesktopPane. I add the JInternalFrames afterwards because they are set up in relation to the size of the JDesktopPane and the height and width of the JDesktopPane are 0 before the JRibbonFrame is set to be visible.

The problem is that the JInternalFrames don't always show up. If one of them shows up then any that are added after it show up as well. The problem is that I need them to show up consistently.

Code:

public class Window extends JRibbonFrame{
    public Window(){
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setExtendedState(JFrame.MAXIMIZED_BOTH);
        Desktop pane = new Desktop();
        getContentPane().add(pane);
        setVisible(true);
        pane.placeComponents();
    }
}
public class Desktop extends JDesktopPane{
    private JInternalFrame frame1, frame2, frame3, frame4;
    public Desktop(){
        super();
    }
    public void placeComponents(){
        frame1 = new JInternalFrame("", true);
        frame1.setVisible(true);
        frame1.setLocation(new Point(0, 0));
        frame1.setSize(new Dimension(400, getHeight()));
        add(frame1);
        frame2 = new JInternalFrame("", true);
        frame2.setVisible(true);
        frame2.setLocation(new Point(frame1.getWidth(), 0));
        frame2.setSize(new Dimension(getWidth() - frame1.getWidth(), 350));
        add(frame2);
        frame3 = new JInternalFrame("", true);
        frame3.setLocation(new Point(frame1.getWidth(), frame2.getHeight()));
        frame3.setSize(new Dimension(600, getHeight() - frame2.getHeight()));
        frame3.setVisible(true);
        add(frame3);
        frame4 = new JInternalFrame("", true);
        frame4.setLocation(new Point(frame1.getWidth() + frame3.getWidth(), frame2.getHeight()));
        frame4.setSize(new Dimension(getWidth() - frame1.getWidth() - frame3.getWidth(), getHeight() - frame2.getHeight()));
        frame4.setVisible(true);
        add(frame4);
    }
}

` Edit: I tried doing this with Window extending JFrame and it worked fine. If anyone could shed any light on why JRibbonFrame screws it up that would be great.

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Eric M
  • 57
  • 1
  • 8

0 Answers0