wood burning stoves*
The moose likes Applets and the fly likes Tryin to do Jbutton disappear. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Tryin to do Jbutton disappear." Watch "Tryin to do Jbutton disappear." New topic
Author

Tryin to do Jbutton disappear.

Mike Hwood
Greenhorn

Joined: Jun 27, 2008
Posts: 1
Hello, tryin to make Jbutton disappear after click. I tried false and also tried contentPane.remove(aButton)
I am not understanding the concept of making the button false after it is true




[edit]Add code tags. CR[/edit]
[ July 04, 2008: Message edited by: Campbell Ritchie ]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
Welcome to JavaRanch

Please use the code button (below the message window) when quoting code; I have added code tags so you can see how much easier it is to read the code.
You have a major error, that you are declaring a local variable called aButton, so the field "aButton" is shadowed.
You also haven't got anything about removing buttons in the actionPerformed method.

Despite many books using that syntax, "addActionListener(this)" is usually bad object-oriented programming. I have written about it here and on this old thread which has recently reappeared.

This appears to be an applet-specific topic, and I think you might get more answers if I transfer it to the Applets forum.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
You are also setting "that felt good" to visible(false) then later in the init() method to visible(true). Try losing the setVisible(true) from the init() method.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tryin to do Jbutton disappear.