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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

draw bound text

Status
Not open for further replies.

esdee

Programmer
Apr 12, 2001
143
US
hi!
i need to draw text bound by a box (inside a component for example). is there any way to do this automatically?
i want to set the width, and when the text is longer it automatically goes to newt line etc ... can anyone help ? thanx
 
Have you looked at the javax.swing.JTextArea component? This displays text and handles line-wrapping.

Tim
 
hmm...thanx! that looks interesting, but i need to implement such behavior in my own components. is there an easy way to do this ?
or should i just look over JTextArea's source code, is that your idea ? :)

------------------------
dev at viewmoresoft.com
tools for your database
 
Well, if you must write your own from scratch, it can't hurt to have a peek at how the Swing component achieves it.
 
Remember that you can always extend the JTextArea to add the behaviour you need.

Cheers,

Dian
 
... assuming he wants to make use of the Swing libraries.
 
thanx, guys!
do you think it would be easy to extend JTextArea over a JButton for example?
Actually in my case i have custom drawn rectangles (i am implementing a flowchart) so implementing a JTextArea over a rectangle seems awkward. i'll test it now, but still would like to hear your thoughts

------------------------
dev at viewmoresoft.com
tools for your database
 
Well, I don't know what are you trying to do, seems like you're doing a kind of "paint". If so, I think that he best way is extending the Swing components.

Depending on your requisites, extendig JLabel could be enough.

Cheers,

Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top