|
-
September 29th, 1999, 08:03 AM
#1
Disabling components in a container when the container is disabled.
Sample code in AWT:
-------------------
import java.awt.*;
class Try {
public static void main(String[] args)
{
Frame frame = new Frame();
Panel panel = new Panel();
Button button = new Button("Click");
panel.add(button);
panel.setEnabled(false);
frame.add(panel);
frame.setVisible(true);
frame.pack();
}
}
By executing the above code the button in the panel gets disabled.
Sample code in Swing:
---------------------
import javax.swing.*;
class Try {
public static void main(String[] args)
{
JFrame frame = new JFrame();
JPanel panel = new JPanel();
JButton button = new JButton("Click");
panel.add(button);
panel.setEnabled(false);
frame.getContentPane().add(panel);
frame.setVisible(true);
frame.pack();
}
}
By executing the above code the button in the panel does not get disabled.
-
September 30th, 1999, 04:37 PM
#2
Re: Disabling components in a container when the container is disabled.
Enable or disable is to a particular component not to all the the components with in that.
You have to disable/enable the specific components rather than panel.
Meher
-
October 1st, 1999, 12:52 AM
#3
Re: Disabling components in a container when the container is disabled.
Ok, Meher, I did disable a particular component, say, a button in a panel. The button got greyed. I had registered the button as a MouseListener. So when I clicked on the disabled button the mouse event got triggered. How is that happening?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|