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
443 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 250 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 250 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jar file executable 12 58
oracle 11g 23 106
servlet web applications   metadata-complete="true" or false 3 109
Java class and jar 3 21
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

840 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