0

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 by LittleMissChoco: n/a

2
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by LittleMissChoco
Featured Replies
  • 1

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

1

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

Edited by mKorbel: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.