Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Internal Frames and JMenuBar

Status
Not open for further replies.

Cabaal

Programmer
Aug 28, 2001
9
US
Currently I have a program which uses a JDesktopPane within a Content Pane to display JInternalFrame's. I also have menu bar which is added to the content pane. The problem is as follows.
When you move a JInternalFrame, with the mouse, it is allowed to go above or "over" the Menu Bar. When you do this, then move the JInternalFrame "off" of the Menu bar the Menu Bar is erased and does not redraw. However, the menu still exists. When you click where the Menu should be, it redraws and displays.
What I really want is the JInternalFrames to not be able to be moved beyond the confines of the JDesktop. The JMenuBar appears to be "over" the JDesktop, thus the JInternalFrames can move above the Menu.
An thoughts?
Thanks,
Cabaal
 
Hi, very sorry but it worked for me so I can't get a solution for your problem... Here is the example that I did:-

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class JIFDemo extends JFrame implements MenuListener
{
private Container contentPane;
public JIFDemo()
{
contentPane = getContentPane();
setSize(300,300);
contentPane.setLayout(null);

addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
);

JMenu menu = new JMenu("File");
JMenuBar menuBar = new JMenuBar();
JMenuItem fileMenu = new JMenuItem("Open");
menu.addMenuListener(this);
menu.add(fileMenu);
menuBar.add(menu);
setJMenuBar(menuBar);

JInternalFrame jif = new JInternalFrame();
jif.setSize(100,100);
jif.getContentPane().setLayout(null);
jif.setBounds(new Rectangle(10,10,100,100));
jif.show();

contentPane.add(jif, null);
}

public void menuSelected(MenuEvent e)
{
}

public void menuDeselected(MenuEvent e)
{
}

public void menuCanceled(MenuEvent e)
{
}

public static void main(String[] args)
{
JIFDemo jd = new JIFDemo();
jd.show();
}
}

Leon
 
I figured it out. Of course it boiled down to something simple. I was using some old code and the old code had the JMenuBar added to the content pane. As a result I was getting some odd behavior when I added it to the JFrame. Sorry, thanks for your suggestions though. I appreciate it. Thanks,
Cabaal
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top