• 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

Confused with JButton

 
Ranch Hand
Posts: 143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm doing a problem where I list five reasons someone might not buy something and it shows up on a JLabel. After that the user should click a button ("Click here") and with each
click one of the labels is removed. I have no idea what I'm doing. Initially they were all splotched in the middle but I think I figured out how to do bounds, but
now no JButton will show up. I've looked through the book and online but just don't understand what I'm doing wrong. The first part is the class and the second
is the main. (I use Eclipse, which has been very helpful.)

Thanks for any help.



 
Ranch Hand
Posts: 273
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You never added your button. I would also recommend doing this.



Their is really no reason for you to assign a variable to the instance of an object in this case. If you was using the instance variable to call certain methods for functionality than it would be different. Since you extend jframe you can just setVisibility to true inside your constructor.


also



 
Ryan Bishop
Ranch Hand
Posts: 143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you.
 
Ryan Bishop
Ranch Hand
Posts: 143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know what you mean with Test(). Is that a field I create or part of a method? It keeps giving me an error.
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ryan Bishop wrote:I don't know what you mean with Test(). Is that a field I create or part of a method? It keeps giving me an error.



In your case it would be "new Resistance();" and can put the "setVisible(true);" inside the constructor of your Resistance class.
 
Ryan Bishop
Ranch Hand
Posts: 143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, I'm an idiot. Thanks.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic