Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Fix JLabel width; is it possible?

843805Feb 4 2007 — edited Feb 6 2007
Hi,
I want to show in a frame some strings that may change at runtime;
I've used a JLabel.

ex.
JLabel label = new JLabel("It's a test");
...
...
...addActionListener...
label.setText("It is not a test;");
Now when the string in the JLabel change, change also the label width,
and this changes the frame size.
I've use a GridBagLayout.
Isn't possible to assign a constant width to a label?
Alternatively, what other components can I use to show string that may change at runtime, without the frame resize problem?
I don't want to use a JTextField because I don't have to process a string.

Thank you in advance.

MargNat
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 6 2007
Added on Feb 4 2007
10 comments
725 views