*
The moose likes Swing / AWT / SWT and the fly likes JButtons, border around text on Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JButtons, border around text on" Watch "JButtons, border around text on" New topic
Author

JButtons, border around text on

Harold Lime
Ranch Hand

Joined: Jul 20, 2009
Posts: 38
I think I'm right in saying the text on a JButton is actually a JLabel.

But can someone tell me how to remove the border from that JLabel given that it is hidden inside the Button? Do I have to subclass JButton to provide this functionality?
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Harold Lime wrote:I think I'm right in saying the text on a JButton is actually a JLabel.

Nope, it's not.

But can someone tell me how to remove the border from that JLabel given that it is hidden inside the Button? Do I have to subclass JButton to provide this functionality?

No need to subclass that I know of.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2152
    
    7
But can someone tell me how to remove the border


The Border belongs to the button. The space can be adjusted as follows:

Harold Lime
Ranch Hand

Joined: Jul 20, 2009
Posts: 38
pete stein wrote:
Harold Lime wrote:I think I'm right in saying the text on a JButton is actually a JLabel.

Nope, it's not.


I stand corrected.

I figured out how to sort it too, I can just omit the default text and then add a JLabel onto the button - easy.

Edit:

Or could do what you said while I was typing my reply...
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
Harold Lime wrote:I think I'm right in saying the text on a JButton is actually a JLabel.

No, as already mentioned.

But can someone tell me how to remove the border from that JLabel given that it is hidden inside the Button? Do I have to subclass JButton to provide this functionality?

Check out the setBorderPainted() and setContentAreaFilled() methods. JButton inherits them from AbstractButton.


bitguru blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JButtons, border around text on
 
Similar Threads
Adding JLabels to a vector
Help designing a GUI
Java Board Game
NX:Some Questions(URLyBird1.3.2)
Inclined Text of JLabel