• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 79262
377
  • 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: 79262
377
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic