File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to make Large JOptionPane?

 
Avin Sinanan
Ranch Hand
Posts: 109
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
John Smith
Ranch Hand
Posts: 84
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 154
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 83
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd probably reccommend using a JTextArea, although the newline character ("\n" not "/n")should work as well.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic