What's the easiest way to nest Menus? You know create
submenus. I have somthing like this in one of my programs but
the last option only get the submenu, im not sure why this is so.
Code:JMenuBar jmb = new JMenuBar(); JMenu options = new JMenu("Options"); JMenu settings = new JMenu(); JMenu help = new JMenu("Help"); JMenu novice = new JMenu("Novice"); JMenu inter = new JMenu("Intermedeate"); JMenu advanced = new JMenu("Advanced"); JRadioButtonMenuItem min1 = new JRadioButtonMenuItem("Min 1"); JRadioButtonMenuItem min3 = new JRadioButtonMenuItem("Min 3"); JRadioButtonMenuItem min5 = new JRadioButtonMenuItem("Min 5"); jmb.add(options); jmb.add(help); // add JMenu options.add(novice); // add the main JMenus options.add(inter); options.add(advanced); bg.add(min1); // add JRadioButtonMenuItems too ButtonGroup bg.add(min3); bg.add(min5); settings.add(min1); // add JRadioButtonMenuItems to JMenu settings.add(min3); settings.add(min5); novice.add(settings); // add JMenu Setting to each JMenu inter.add(settings); advanced.add(settings);




Reply With Quote