Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JButton text padding  RSS feed

 
Krep Lock
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm fussing about with a GUI and find the JButton objects require way too much "padding" before they decide to display my button text in the desired font size. I wonder if anyone here knows how to reduce the blank spacing along the button sides to make more room for text?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can change the Insets of a component. With a JButton it is as simple as something like:



Where the constructor of Insets is top, left, bottom, right.

The API is a great place to find this kind of info.
 
Krep Lock
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That answered it nicely, thanks. I did review the API docs, but expected something on the order of "padding" or "spacing". <shrug>
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!