Im having problems with my code. :(
the code should. the submenu for my menu should be on a radio button type.
here's my first code:

public ... { 
//for background
   JMenuItem image = new JMenuItem("Images");
    JMenuItem music = new JMenuItem("Music");
    //submenu of music
    JRadioButtonMenuItem play = new JRadioButtonMenuItem("Play");
    JRadioButtonMenuItem loop = new JRadioButtonMenuItem("Loop");
    JRadioButtonMenuItem stop = new JRadioButtonMenuItem("Stop");
    ButtonGroup group = new ButtonGroup();
}


public void init(){
    	con.setLayout(new FlowLayout());
		setJMenuBar(mainBar);
		mainBar.add(menu1);
		mainBar.add(menu2);
		mainBar.add(menu3);
		menu1.add(open);
		menu1.add(save);
		menu1.add(reset);
		menu2.add(setFont);
		menu2.add(setColor);
		menu3.add(image);
		menu3.add(music);
		music.add(play);
		music.add(loop);
		music.add(stop);
}

when i try to run it. the Music menu doesnt appear. it will changed to Play(radiobutton)
does the button group will help? when i tried to use the button group nothing happens :(

Thanks :)

Edited 5 Years Ago by LittleMissChoco: n/a

add JRadioButtonMenuItem to the ButtonGroup, then only one JRadioButton from ButtonGroup could be selected

Edited 5 Years Ago by mKorbel: n/a

This question has already been answered. Start a new discussion instead.