File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes How to make Large JOptionPane? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to make Large JOptionPane?" Watch "How to make Large JOptionPane?" New topic
Author

How to make Large JOptionPane?

Avin Sinanan
Ranch Hand

Joined: Nov 07, 2001
Posts: 109
hello there is was wondering if anyone out there knows how to make a large JoptionPane.
Whenever I make a JOptionPane and I try to fit a paragraph in it the JOptionPane just gets longer and longer until it is as long as the JFrame and the words that cannot fit into the JOptionPane are not show.
I can create a JOptionPane using:
JOptionPane.showMessageDialog(frame,
"Eggs aren't supposed to be green.",
"Inane custom dialog",
JOptionPane.INFORMATION_MESSAGE,
icon);
But if intstead of "Eggs aren't suppose to be green" I wanted a long paragraph ..say at least 100 words. How do I do this
I tried using the "/n" (next line) after every sentence but it doe snot work.
Does anyone have any ideas?
Thanks in advance.


yours respectfully<br />Avin Sinanan
John Smith
Ranch Hand

Joined: Jul 20, 2001
Posts: 84
I believe you can use HTML for the text. For example, instead of "Eggs aren't supposed to be green.", try doing something like:

[ February 04, 2002: Message edited by: Randy Gordon ]
Elouise Kivineva
Ranch Hand

Joined: Feb 07, 2002
Posts: 154
You can put a JTextArea in a JOptionPane. You can also put a JScrollPane in a JOptionPane.
JTextArea myTArea= new JTextArea(17, 20);
JScrollPane myScroller=new JScrollPane( myTArea);
String longText="jadda jadda... jadda jadda";
myTArea.setText(longText);
JOptionPane.show...(myParentContainer, myScroller, myTitle, JOptionPane.PLAIN_MESSAGE);
Daniel Searson
Ranch Hand

Joined: Dec 03, 2000
Posts: 83
I'd probably reccommend using a JTextArea, although the newline character ("\n" not "/n")should work as well.


- Daniel
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to make Large JOptionPane?