Some questions on swing - please help

S

Soundar

Question 1:
---------------
If I set a JPanel to not enabled

pane.setEnabled(false);

I am still able to select the components that are the panel's children.
Coming from a VB background, I find this strange. Am I doing something
wrong? Do I have to disable each child one by one?

Question 2:
--------------
The JCheckbox component has a constructor

JCheckbox (String label, Icon icon)

But do I not need two icons, one when it is checked and another one
when it is unchecked? I tried this constructor and of course the image
does not change whether it is checked or unchecked.

Thanks
 
H

hilz

Soundar said:
Question 1:
---------------
If I set a JPanel to not enabled

pane.setEnabled(false);

I am still able to select the components that are the panel's children.
Coming from a VB background, I find this strange. Am I doing something
wrong? Do I have to disable each child one by one?

Question 2:
--------------
The JCheckbox component has a constructor

JCheckbox (String label, Icon icon)

But do I not need two icons, one when it is checked and another one
when it is unchecked? I tried this constructor and of course the image
does not change whether it is checked or unchecked.

Thanks

That is not the default behavior of a checkbox, but you can implement that
easily.
Add an action listener tochange the icon when the checkbox is
selected/unselected.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top