Re: [JAVA + NETBEANS] "disobedient" buttons :)
Mariano wrote:
Sub: [JAVA + NETBEANS] "disobedient" buttons :)
Notes:
1) that your own web-interface to usenet cannot
properly format thread subjects containing '[' apparently..
<http://groups.google.com/group/comp.lang.java.programmer/msg/3f015a49109f7641>
...so it is probably best to avoid using them.
2) What a load of old cobblers, even jokingly.
You should learn how to use Java before you go
blaming the GUI components.
(snip)
...How can I resolve it?
this is a part of code:
I doubt it is the correct part - I always recommend
SSCCE's, which we can compile and run....
what is wrong??
Here is an SSCCE showing a button acting
exactly as I would expect it to.
You might try.. removing every part of your program,
until it either equals my program, or works, then the
last line you remove was the problem, Or..
Submtiting your own SSCCE that actually compiles
to demonstrate the problem you are seeing.
<sscce>
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class DisabledButtons {
public static void main(String[] args) {
JFrame f = new JFrame("Disabled Button");
f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
Container c = f.getContentPane();
c.setLayout( new GridLayout(0,1) );
final JButton b1 = new JButton("Button 1");
c.add(b1);
final JCheckBox cb1 = new
JCheckBox("Checkbox 1", true);
cb1.addActionListener( new ActionListener(){
public void actionPerformed(ActionEvent ae) {
b1.setEnabled( cb1.isSelected() );
}
} );
c.add( cb1 );
f.pack();
f.setVisible(true);
}
}
</sscce>
More information on the SSCCE..
<http://www.physci.org/codes/sscce>
Andrew T.