Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 399
  • Last Modified:

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
0
tegz
Asked:
tegz
  • 3
  • 2
1 Solution
 
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
 
RomanRegaCommented:
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
 
tegzAuthor Commented:
Sorry for the delayed response, thank you so much!
0
 
RomanRegaCommented:
No problem :)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now