views:

123

answers:

1

I am using Netbeans Swing GUI builder to design my app's GUI. I have a JTextField tf and a JCheckBox cb.

Now, I want that the tf is enabled only when the cb is both enabled and selected.

I am performing the below steps to perform this in Netbeans:

  1. Right click on tf >> Properties >> Binding
  2. Click on button ... at the right of enabled
  3. Binding Source: tf

    Binding Expression: ${selected}

Now, in the above steps, binding expression can be set either to ${selected} or to ${enabled}.

But according to my needs, the binding expression should be something like ${selected} && ${enabled}.

I tried the above expression too but it didn't work.

How can I do that through Netbeans?

+1  A: 

The expression you want is,

${enabled && selected}

Type the expression manually into the field.

You must do one additional thing. Go to the Advanced tab, and change the Update Mode from Read/write to Read-Only. Otherwise, the disablement of the text field will also disable the checkbox.

Noel Ang
Which Advanced tab you are talking about?
Yatendra Goel
From the Bindings dialog, in the sub-dialog for editing the "enabled" binding, there is an Advanced tab. At least, on NetBeans 6.7, the version I'm using.
Noel Ang