java - Printing out .txt file with JOptionPane -
i'm trying list of words have scroll instead of window running off screen. scroller working can't dimension work. says ( new dimension( 200, 400 )) ;
has error in it. cannot find symbol
import javax.swing.jdialog; import javax.swing.*; import java.util.*; import java.io.*; public class print1 { public static void main(string [] args) throws ioexception { string input = ""; bufferedreader reader = new bufferedreader(new filereader("wordlist.txt")); string line = null; while ((line = reader.readline()) != null) { input += line + "\n"; } reader.close(); jtextarea textarea = new jtextarea(input); jscrollpane scrollpane = new jscrollpane(textarea); textarea.setlinewrap(true); textarea.setwrapstyleword(true); scrollpane.setpreferredsize( new dimension( 200, 400 )) ; joptionpane.showmessagedialog(null, scrollpane, "complete word list:", joptionpane.plain_message); } }
maybe you:
public class joptiontest { private string text; public void readfilecontent() throws filenotfoundexception{ text = new scanner( new file("install.txt") ).usedelimiter("\\a").next(); } public string getfilecontent(){ return this.text; } public void displayjoptiontest(){ joptionpane.showmessagedialog(null, text, "stackoverflow test", joptionpane.error_message); } public static void main(string [] args) throws filenotfoundexception{ joptiontest test = new joptiontest(); test.readfilecontent(); test.displayjoptiontest(); } }
Comments
Post a Comment