• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hidden buttons

 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created an applet that extends JApplet. The applet paints a square with the upper left hand corner at 10,10, and is 40 pixels across. I want to create a button that goes inside the square, like b.setBounds( 20 , 20 , 20 , 20 ), but is not visible. When you click inside the square (the button), the square changes colors (I have a Color array that it cycles through).
Problem is, if I do a setVisible( false ), the button is hidden, but it does not function. When I set it to true, the button takes up the whole applet content pane. Any suggestions?
Thanks!
Jason
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jason,
Try setting your JApplet layout to null. This should stop the button from taking up the entire applet.
Regards,
Manfred.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic