• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

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: 71722
312
  • 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: 71722
312
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic