aspose file tools
The moose likes Swing / AWT / SWT and the fly likes Disabling a JPanel and all it's components Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Disabling a JPanel and all it Watch "Disabling a JPanel and all it New topic
Author

Disabling a JPanel and all it's components

Tanveer Rameez
Ranch Hand

Joined: Dec 11, 2000
Posts: 158
Hi
I am having a problem. Let me explain by simplifying the GUI to a simple frame in which I have a JCheckbox and a JPanel mypanel.
mypanel has a Textfield tf,JComboBox cmb as it's components.
So now if I deselect the JCheckbox, all the components in the mypanel should be disabled. I used a code like:
[code]
mycheckbox.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
if(mycheckbox.isSelected())
mypanel.setEnabled(true);
else
mypanel.setEnabled(false);
}
});
[code]
but the components inside the panels are not disabled. In my actual program I have a large number of different kinds of components in mypanel.So disabling/enabling each of them on each actionPerformed of the mycheckbox will be laborious. Isn't there any way by which I can disable/enable the mypanel to disable/enable all the components in it?
regards
Tanveer


Author of JPhotoBrush Pro (www.jphotobrushpro.com)
Gregg Bolinger
Ranch Hand

Joined: Jul 11, 2001
Posts: 15229

Ok, here is what to do.



------------------
Happy Coding,
Gregg Bolinger
Tanveer Rameez
Ranch Hand

Joined: Dec 11, 2000
Posts: 158
hi
thanks for the help. Gee, I forgot about that method. I should have looked at the APIs but that never crossed my mind.
thanks again.
Regards
Tanveer
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Disabling a JPanel and all it's components
 
Similar Threads
enalbe, disable checkboxes
How to disable Menubar
Solution to Disable a Panel
MVC With Action Classes - is it possible?
java repaint the frame or the panel?