Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Bottom JMenuItems go behind JTabbedPane that is directly below this main menu when the first tab in the JTabbedPane is selected

Posted on 2006-11-28
6
Medium Priority
?
472 Views
Last Modified: 2010-07-27
I am working with a Java Swing GUI.  I have a JMenuBar on the main JFrame with JMenus and JMenuItems.  Directly below this menu bar I have a JTabbedPane.  When I expand the menus in the Main Menu the bottom menu items disappear behind the JTabbedPane when the first tab in the JTabbedPane is selected.  When the second tab in the JTabbedPane is selected everything is fine.  How do I fix this?

Thanks,
Dave
0
Comment
Question by:gdkinney_2
6 Comments
 
LVL 10

Accepted Solution

by:
ADSLMark earned 1000 total points
ID: 18030288
Example code:

import java.awt.*;
import javax.swing.*;

public class TabMenuExample extends JFrame
{
    public TabMenuExample()
    {
        this.setJMenuBar(CreateMenuBar());
        getContentPane().add(CreateTabbedPane());
        this.setSize(800,600);
        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    }

    public JTabbedPane CreateTabbedPane()
    {
        JTabbedPane tab = new JTabbedPane();

        for(int i=0;i<10;i++)
        {
            JPanel pnl = new JPanel();
            tab.addTab("Tab" + i, null, pnl, "Tab" + i);
        }
        tab.setSelectedIndex(0);
        return tab;
    }

    public JMenuBar CreateMenuBar()
    {
        JMenuBar menubar = new JMenuBar();
        JMenu menu = new JMenu("Testing Menus");

        for(int i=0;i<10;i++)
        {
            JMenuItem menuitem = new JMenuItem("Menu Items " + i);
            menu.add(menuitem);
        }
        menubar.add(menu);
        return menubar;

    }

    public static void main(String[] args)
    {
        TabMenuExample test = new TabMenuExample();
        test.setVisible(true);
    }
}

Works for me, using java version 1.5.0_09.

Mark
0
 
LVL 14

Assisted Solution

by:hoomanv
hoomanv earned 1000 total points
ID: 18031375
The problem is that you are mixing awt (heavy weight) and swing (light weight) components and that heavies win the competition and stay on top
http://java.sun.com/products/jfc/tsc/articles/mixing/
0
 

Author Comment

by:gdkinney_2
ID: 18031670
hoomany,
   I think you are correct we are using a GOTS product that I believe has AWT components.  I emailed the developers today to confirm this.  I'll check back tomorrow if my assumption is correct.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question