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 :)

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

exactly :-)

it doesnt work. i've tried that already :(

the Music menu will not appear. it will be changed to the Play radio submenu :(

got it :) add group and then the music menu :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.