to specify compact text style for JButton

Hi,

I hope to make the text on the JButton compact. This is comparable to set the "internal margin" attribute for a Text box in the Microsoft WORD. The default margin is none zero. If you set one of the left/right/top/bottom to be zero, a little more text can be displayed in one line/column when the Text box size is not changed.

I didn't find where can I set this for the JButton. The JTextComponent has a "setMargin(Insets m) " method to achieve this. But JButton is not a subclass of JTextComponent. JButton has setFont() method, but font attribute doesn't seem to deal with the text line margin. Font class itself has "getLineMetrics()". I guess it's related but there's no "setLineMetrics" so that I can set the internal text margin.

Currently, my Button has to be certain large to display its default font-size (12, Times new roman) text. If I shrink the button, text will be "..." but the total button size is actually enough to display the text, if I can set the line' left and right margin =0; Besides, I must use "center" alignment for the text.

Anyone has idea?

Thanks

[1122 byte] By [angelflareea] at [2007-11-27 10:59:19]
# 1

> The JTextComponent has a "setMargin(Insets m) " method to achieve this.

>But JButton is not a subclass of JTextComponent

AbstractButton also has a setMargin(...) method.

camickra at 2007-7-29 12:22:13 > top of Java-index,Desktop,Core GUI APIs...
# 2

> The JTextComponent has a "setMargin(Insets m) " method to achieve this

as does AbstractButton()

Michael_Dunna at 2007-7-29 12:22:13 > top of Java-index,Desktop,Core GUI APIs...
# 3

Oh, yes. Too many methods in AbstractButton that I didn't notice it.

It works.

Thank you guys.

angelflareea at 2007-7-29 12:22:13 > top of Java-index,Desktop,Core GUI APIs...