1

I have a problem I'm trying to disable JButton with setEnabled(false) like this:

ButtonNewCustomer.setEnabled(false);

But this didn't work so then I imported the Applet packages, but still not working, then I discovered that I also needed to use extends Applet in the class, but the problem is that I'm already using extends for other things like this:

public class GUI4EX extends JFrame implements ActionListener {
...
}

I have tried to add Applet, but this dont't work! Is there a way to solve this? Thanks!

EDIT: It's working know! The problem was a misspelling of the buttonNewCustomer. The first letter 'b' was 'B'. Sorry! And thanks for the help!

skaffman
  • 398,947
  • 96
  • 818
  • 769
3D-kreativ
  • 9,053
  • 37
  • 102
  • 159
  • 1
    `setEnabled(false)` will disable, not enable, the button. You don't need to extend Applet, not sure where you got that from. – Aleks G Mar 13 '12 at 10:16
  • 1
    Extend Applet - better JApplet, which is a kind of a Frame. JApplet is the Swing form, and fits to JButton. If you need a JFrame inside, create an attribute JFrame. Create a SSCE and provide complete errormessages. – user unknown Mar 13 '12 at 10:18
  • 1
    There's a working solution in this thread: [How to disable javax swing jbutton in java][1] [1]: http://stackoverflow.com/questions/1625855/how-to-disable-javax-swing-jbutton-in-java – Marcel Schutte Mar 13 '12 at 10:24
  • 1
    I't working! Please see my edit! – 3D-kreativ Mar 13 '12 at 10:25

2 Answers2

2

use setEnabled(true) to enable button...

David Kroukamp
  • 36,155
  • 13
  • 81
  • 138
1

Make sure that you are disabling/enabling your button before setting the frame's visibility.

Taryn
  • 242,637
  • 56
  • 362
  • 405
Jatin
  • 318
  • 1
  • 2
  • 9
  • 2
    wrong, there is no sequential dependency on setting those properties (toplevel parent visible vs. child enabled) – kleopatra Mar 13 '12 at 10:32