Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #2075 > unrolled thread

set compact font line on

Started byWenj.Ma@gmail.com.remove-dii-this
First post2011-04-27 15:37 +0000
Last post2011-04-27 15:37 +0000
Articles 3 — 3 participants

Back to article view | Back to comp.lang.java.gui


Contents

  set compact font line on Wenj.Ma@gmail.com.remove-dii-this - 2011-04-27 15:37 +0000
    Re: set compact font line "Knute Johnson" <knute.johnson@THRWHITE.remove-dii-this> - 2011-04-27 15:37 +0000
      Re: set compact font line "Ray Ma" <ray.ma@THRWHITE.remove-dii-this> - 2011-04-27 15:37 +0000

#2075 — set compact font line on

FromWenj.Ma@gmail.com.remove-dii-this
Date2011-04-27 15:37 +0000
Subjectset compact font line on
Message-ID<1184772963.252964.185520@x35g2000prf.googlegroups.com>
  To: comp.lang.java.gui
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

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [next] | [standalone]


#2076 — Re: set compact font line

From"Knute Johnson" <knute.johnson@THRWHITE.remove-dii-this>
Date2011-04-27 15:37 +0000
SubjectRe: set compact font line
Message-ID<rNrni.89558$aP2.81923@newsfe16.lga>
In reply to#2075
  To: comp.lang.java.gui
Wenj.Ma@gmail.com wrote:
> 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
> 

You can always adjust the size of the font.  AbstractButton has a method 
setMargin(), from the docs;

"public void setMargin(Insets m)

     Sets space for margin between the button's border and the label. 
Setting to null will cause the button to use the default margin. The 
button's default Border object will use this value to create the proper 
margin. However, if a non-default border is set on the button, it is 
that Border object's responsibility to create the appropriate margin 
space (else this property will effectively be ignored).

     Parameters:
         m - the space between the border and the label"

-- 

Knute Johnson
email s/nospam/knute/

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2092 — Re: set compact font line

From"Ray Ma" <ray.ma@THRWHITE.remove-dii-this>
Date2011-04-27 15:37 +0000
SubjectRe: set compact font line
Message-ID<1184877697.926527.36590@m37g2000prh.googlegroups.com>
In reply to#2076
  To: comp.lang.java.gui
Yes, You are right.
It works. thanks.

>
> You can always adjust the size of the font.  AbstractButton has a method
> setMargin(), from the docs;
>
> "public void setMargin(Insets m)
>
>      Sets space for margin between the button's border and the label.
> Setting to null will cause the button to use the default margin. The
> button's default Border object will use this value to create the proper
> margin. However, if a non-default border is set on the button, it is
> that Border object's responsibility to create the appropriate margin
> space (else this property will effectively be ignored).
>
>      Parameters:
>          m - the space between the border and the label"
>
> --
>
> Knute Johnson
> email s/nospam/knute/

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.gui


csiph-web