Meaningless Drivel is fun!*
The moose likes Swing / AWT / SWT and the fly likes making the message wrap in a JDialog Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "making the message wrap in a JDialog" Watch "making the message wrap in a JDialog" New topic
Author

making the message wrap in a JDialog

Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

i have the following code which works ok except the message doesn't wrap, so the JDialog(the lucky recipient of the return value from getMessage()), is one long...long...long..line


can i perhaps set the width of the JDialog?


SCJP
Visit my download page
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
set it as the text of a JTextArea (in scrollPane) with lineWrap set to true
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

it is one of several classes that implement the same interface. the main program treats them all the same using a JDialog to display the message

i suppose i could add some newline characters, but after what i had to do to turn it into a string in the first place
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

well it's ugly but it works
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
I still think it's simpler with a textArea.
Run this to see what it looks like.



 
It is sorta covered in the JavaRanch Style Guide.
 
subject: making the message wrap in a JDialog