• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Tryin to do Jbutton disappear.

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Marshal
Posts: 80282
432
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 80282
432
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Happily living in the valley of the dried frogs with a few tiny ads.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic