Hello, Is there a way of setting text for a JLabel after a certain amount of
empty characters.
For example, I want to avoid doing this
JLabel label = new JLabel();
label.setText(" Book Name =")
Thanks
Steve W. Jackson - 14 Jan 2004 22:30 GMT
>:Hello, Is there a way of setting text for a JLabel after a certain amount of
>:empty characters.
[quoted text clipped - 4 lines]
>:
>:Thanks
You'll find that using those spaces still won't work right anyway in
some cases. The text of a JLabel is usually centered on the label. To
have control over that implies that you need control over the size of
the JLabel, possibly over its placement with its parent container, and
even the Font used to display its text. In our app, we specified the
font we wanted to use, then devised a means of building JLabels and
other components using a formula for specifying the sizes (min, max, and
preferred).
= Steve =

Signature
Steve W. Jackson
Montgomery, Alabama
ak - 15 Jan 2004 00:49 GMT
> Hello, Is there a way of setting text for a JLabel after a certain amount of
> empty characters.
[quoted text clipped - 4 lines]
>
> Thanks
first determine needed length then add EmptyBorder to JLabel:
label.setBorder(new EmptyBorder(0, length, 0, 0));
--
____________
http://reader.imagero.com the best java image reader.
Thomas Weidenfeller - 15 Jan 2004 07:28 GMT
> Hello, Is there a way of setting text for a JLabel after a certain amount of
> empty characters.
> For example, I want to avoid doing this
>
> JLabel label = new JLabel();
> label.setText(" Book Name =")
Use a suitable layout manager instead, and align all components in that
column to the right.
Also, the common standard in GUIs is to separate the label and the data
with a ":", not with " =".
/Thomas
Fred L. Kleinschmidt - 15 Jan 2004 15:06 GMT
> Hello, Is there a way of setting text for a JLabel after a certain amount of
> empty characters.
[quoted text clipped - 4 lines]
>
> Thanks
If you are using a layout manager that controls its size, or setBounds
to specify the size, use:
label.setHorizontalAlignment(SwingConstants.RIGHT);

Signature
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Common User Interface Services
M/S 2R-94 (206)544-5225