wood burning stoves 2.0
The moose likes Swing / AWT / SWT and the fly likes JMenu + JPanel Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JMenu + JPanel Problem" Watch "JMenu + JPanel Problem" New topic

JMenu + JPanel Problem

Gordon Freeman

Joined: Jul 19, 2005
Posts: 1
OK, i know it might be a little strange what I'm trying to do but none the less I have to do it. So here is my problem:
I neeed to add a JPanel, containing several components, as a JMenuItem to a JMenu, and have it behave normally(allowing me to select options, check/uncheck boxes and any other similar activities).
I managed to get it to show up, but the form that apears in the JMenu is uselles. All components from inside the JPannel do not react the way they should. It's like the events are't even passed . Here is the code I have so far (any help is MOSTLY appreciated):

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

public class Post {

static GridBagConstraints constraints = new GridBagConstraints();
static JFrame frame = new JFrame("Advanced Menu");
JPanel aditionalPane = new JPanel(new GridBagLayout());;
JCheckBox jco;
JCheckBox jct;

private JPanel advancedOpts(){

constraints.gridx = 0;
constraints.gridy = 0;
jco = new JCheckBox("JCheck One", true);

constraints.gridy = 1;
jct = new JCheckBox("Jcheck Two", true);

return this.aditionalPane;

private JMenuBar advAsMenu(){

JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("Advanced Menu");
JMenuItem item = new JMenuItem();

return menuBar;

public static void main(String[] args) {

Post am = new Post();

frame.setMaximumSize(new Dimension(500,500));
frame.setMinimumSize(new Dimension(500,500));
frame.setPreferredSize(new Dimension(500,500));
frame.pack( );

Thank you all in advance for all your time and support.
I agree. Here's the link: http://aspose.com/file-tools
subject: JMenu + JPanel Problem
It's not a secret anymore!