• Post Reply Bookmark Topic Watch Topic
  • New Topic

Confused with JButton  RSS feed

 
Ryan Bishop
Ranch Hand
Posts: 143
5
  • Mark post as helpful
  • send pies
  • 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.



 
Charles Sexton
Ranch Hand
Posts: 273
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thank you.
 
Ryan Bishop
Ranch Hand
Posts: 143
5
  • Mark post as helpful
  • send pies
  • 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.
 
K. Tsang
Bartender
Posts: 3632
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Ah, I'm an idiot. Thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!