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
451 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
java imports not found 4 71
swing controls 2 38
Github api to fetch the number of collaborators in a git repo 1 70
Overriding a method 3 15
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

752 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