This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JButton with no Border

 
Garandi Garandi
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to add a JButton with no border, so that if I set the button to be disabled the button should not be visible.
Thank you
Garandi
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, losing the Border of a JButton does not make it invisible. It only removes the border. To do this you simply use the setBorderPainted(boolean) method of JButton.
If you want the button to disappear if it is disabled, you will have to remove it from whatever container you have it on. container.remove(button). And don't foget to call repaint and/or revalidate so that the changes take affect.
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to make the button invisible, you can call

to make it visible, use visible(true).
this works most nicely!
Chantal
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic