Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pblm with JFrame and JPanel

Status
Not open for further replies.

sujitopics

Programmer
Oct 9, 2001
69
KR
Hi

I am new to java.
Pl help me.

I have a JFrame Class Which contains a MenuItem.

and a JPanel Class Which Contains a RadioButton.

When the user selects the radio button, that menu item should get disabled.

I am facing a lot of pblms with this one in my project.

Please help me
Thanksinadvance
Yours
Suji
 
Hi,
Add an actionListener on ur radio button and trap it in the action performed and then disable the menuitem and enable it again on unchecking ur radion button. The code will be something like this.

// first add the menuitem on the menu object
// and add the menu object to the menubar assume
// that the menu item's name is menuItem

JRadioButton button = new JRadioButton("buttonName");
button.addActionCommand("actionCommand");
button.addActionListener(this);

public void actionPerformed(ActionEvent ae)
{
if(ae.getActionCommand().equals("actionCommand"))
{
if(button.isSelected())
{
menuItem.setEnabled(false);
}
else
{
menuItem.setEnabled(true);
}
}
}


Hope this helps,

Reddy316
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top