Java JButton sizing issue

Status
Not open for further replies.
Hi all. I'm making a little JAVA application and I'm having trouble making properly formatted JButtons. It's not a huge deal, just a pet peeve that I like my components to be sized in such a way that the contents fill the component quite well.

Anyway, I have 4 buttons, labelled "+ +", "+", "-", and "- -" buttons total. I've seen buttons in applications left and right that are quite small. In my case, I'd estimate the plus sign as maybe 10x10 pixels, but the minimum size of a button that doesn't truncate it to "..." is 40 pixels wide... which strikes me as a bit ridiculous because I'm almost certain the plus sign is thinner than the ellipsis.

Am I going to have to go through and make some custom icons for the buttons, or is there a way to better fit the button to my text?
 
Store the button's size, and keep using it:
JButton jb = new JButton("+");
Dimension prefSize = jb.getPreferredSize();
jb.setText("-");
jb.setPreferredSize(prefSize);

taken from Java Programming [Archive] - Button resizing
Im assuming you can adjust the size by increasing the size of the letters in your case the symbols.
 
Status
Not open for further replies.
Back
Top Bottom