java - JOptionPane.showMessageDialog truncates JTextArea message -


my java gui application needs show text end-user, joptionpane utility methods seem fit. moreover, text must selectable (for copy-and-paste) , long (~100 words) must fit nicely window (no text off screen); ideally should displayed @ once user can read without needing interact, scrollbars undesirable.

i thought putting text jtextarea , using message in joptionpane.showmessagedialog easy appears truncate text!

public static void main(string[] args) {   jtextarea textarea = new jtextarea();   textarea.settext(gettext()); // string of ~100 words "lorem ipsum...\nfin."   textarea.setcolumns(50);   textarea.setopaque(false);   textarea.seteditable(false);   textarea.setlinewrap(true);   textarea.setwrapstyleword(true);   joptionpane.showmessagedialog(null, textarea, "truncated!", joptionpane.warning_message); } 

dialog truncated text

how can text fit entirely option pane without scrollbars , selectable copy/paste?

import java.awt.*; import javax.swing.*;  public class textareapreferredheight2 {  public static void main(string[] args)  {   string text = "one 2 3 4 5 6 7 8 9 ten ";   jtextarea textarea = new jtextarea(text);   textarea.setcolumns(30);   textarea.setlinewrap( true );   textarea.setwrapstyleword( true );   textarea.append(text);   textarea.append(text);   textarea.append(text);   textarea.append(text);   textarea.append(text);   textarea.setsize(textarea.getpreferredsize().width, 1);   joptionpane.showmessagedialog(    null, textarea, "not truncated!", joptionpane.warning_message);  } } 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -