Creating a JPanel on a JDesktopPane below a MenuBar

http://java.sun.com/docs/books/tutorial/uiswing/components/example-1dot4/InternalFrameDemo.java

I've got a JDesktopPane that is based on the one above, but I need to create a JPanel just below the MenuBar, is this possible still allowing JInternalFrames to be created in the JDesktopPane.

Thanks in advance
tegzAsked:
Who is Participating?
 
RomanRegaConnect With a Mentor Commented:
Then let's try like this:  

 public InternalFrameDemo() {
        super("InternalFrameDemo");
       
        this.setLayout(new BorderLayout());
        setJMenuBar(createMenuBar());        
        //Make the big window be indented 50 pixels from each edge
        //of the screen.
        int inset = 50;
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        setBounds(inset, inset,
                  screenSize.width  - inset*2,
                  screenSize.height - inset*2);
       
       
       

        //Set up the GUI.
        desktop = new JDesktopPane(); //a specialized layered pane
       
        //setContentPane(desktop);
        this.add(desktop, BorderLayout.CENTER);
        createFrame(); //create first "window"
       
 
        //Make dragging a little faster but perhaps uglier.
        desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
        JPanel pane=new JPanel(new FlowLayout());
        pane.setBounds(new Rectangle(0,0,screenSize.width- inset*2, 100));
        pane.add(new JButton("Bye"));
        pane.add(new JButton("Bye"));
        this.add(pane, BorderLayout.NORTH);
    }


0
 
RomanRegaCommented:

This should be a good start:


    public InternalFrameDemo() {
        super("InternalFrameDemo");

        //Make the big window be indented 50 pixels from each edge
        //of the screen.
        int inset = 50;
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        setBounds(inset, inset,
                  screenSize.width  - inset*2,
                  screenSize.height - inset*2);

        //Set up the GUI.
        desktop = new JDesktopPane(); //a specialized layered pane
        createFrame(); //create first "window"
        setContentPane(desktop);
        setJMenuBar(createMenuBar());
 
        //Make dragging a little faster but perhaps uglier.
        desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
        JPanel pane=new JPanel(new FlowLayout());
        pane.setBounds(new Rectangle(0,0,screenSize.width- inset*2, 100));
        pane.add(new JButton("Bye"));
        pane.add(new JButton("Bye"));
        desktop.add(pane);
    }

0
 
tegzAuthor Commented:
this is great, but i still need to be able to see the panel when a JinternalFrame is maximised
0
 
tegzAuthor Commented:
Sorry for the delayed response, thank you so much!
0
 
RomanRegaCommented:
No problem :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.