File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Urgent - pls help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Urgent - pls help" Watch "Urgent - pls help" New topic

Urgent - pls help

Sajee Joseph
Ranch Hand

Joined: Jan 17, 2001
Posts: 200
I have a frame with a menu. Now just below the menu i have a JButton. My problem is that when i click on the menu, i get my menuitems. But unfortunately, the menuitem is almost at the same position as the JButton. But instead of the JMenuItem appearing in front of the JButton, i get the JButton in front of JMenuItem . Thus my JMenuItem is partially hidden bu the JButton. How do i overcome this. What i want is when i click on the menu, the menuitem should come over the JButton.
I hope u guys help me out.
Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
if you place the button in the default layer, the menu would cover the button as it is painted in another layer (above the default one). (see the API for JRootPane, and the swing tutorial for detailed information.)
have you added the button this way?:
JFrame f = new JFrame();
Container content = f.getContentPane();
content.setLayout(new BorderLayout()); //or whatever layout
content.add(new JButton("under menu"), BorderLayout.NORTH);
JMenuBar bar = new JMenuBar();
// configure menubar
I agree. Here's the link:
subject: Urgent - pls help
It's not a secret anymore!