Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JLabel line wrap problem

Status
Not open for further replies.

Oxymoron

Technical User
Dec 17, 2000
168
GB
hi.
I have a JLabel which displays what is being written in a corresponding JTextArea.
Of course with JTextArea there is no problem line wrapping, but how would I acheive the same with a JLabel, I really can't think of how the single line String it displays can be wrapped.

Is there a way of telling when the last character added to the label is near the edge of the label's viewable contants, and then add a "\n" newline character??
--------------------------------------------------------

One other question regarding the JLabel is that when a character is enetered in the JTextArea it should appear in the JLabel, however it is not until the next character is entered that the last character appears???? anyway of getting around this???
---------code----------------------
stringMessage = textArea.getText();
label.setText(stringMsg);
-----------------------------------

any suggestions for these two questions are very welcome!
cheers
Oxy
we are all of us living in the gutter.
But some of us are looking at the stars.
 
If you're not married to the idea of using a JLabel, why not use a JTextArea instead? If you don't put it in a scrollable pane and set the background color to match your frame, then it will serve the same purpose as the JLabel - except you can set the line wrap property. "When you have eliminated the impossible, whatever remains, however
improbable, must be the truth." ~ Arthur Conan Doyle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top