Solved

wordwrap for Label text ?

Posted on 2001-08-08
5
383 Views
Last Modified: 2010-10-05
hello,
here is a simple one.
i would like to know if its possible to wordwrap the text in Label. (not JLabel).
if so, how???

thanks
Ori
0
Comment
Question by:o_helman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 

Expert Comment

by:raga
ID: 6363619
No, there is no option for wordwrap in Label.
But,try setting the size of the Label and give the label string more than the size. Then it may help. Let me know.
0
 
LVL 3

Expert Comment

by:dnoelpp
ID: 6363622
As far as I know this is not possible. If you need multi-line Label, define a subclass of Panel and set its LayoutManager to new GridLayout(0, 1) and add a Label for each line.
0
 
LVL 3

Expert Comment

by:dnoelpp
ID: 6363624
No, raga, I already tried this.
0
 
LVL 15

Expert Comment

by:mohan_sekar
ID: 6363631
Hi,

    I think there is no direct method available for that.
Anyhow, try this link

http://java.cs.vt.edu/dev/kfc/jp.kyasu.editor.TextEditor.html

:-)

Mohan
0
 
LVL 26

Accepted Solution

by:
ksivananth earned 50 total points
ID: 6363718
Hi,
 
   instead of using the Label, use the TextArea and set the background and foreground property by getting it from the container.

 for eg,

  JPanel pnl = new JPanel() ;
  JTextArea ta = new JtextArea() ;

  ta.setBackground( pnl.getBackground() ) ;

 like this set the foregroung property too. So ti will look like a label.Or use the drawString() method of the graphics class. I have implemented this ideas in my app.

thank u
siva

 
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This video teaches viewers about errors in exception handling.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question