swing - Java GUI - displaying text in a new window from another method -


i have following interface structure: frame in can browse , choose files (in class file), when press button reads files (in separate class file) , sends them processing (in class file, 3rd). processing irrelevant question.

when press processing button mentioned before, new window (frame) launches. in window have textarea in want display console output while processing takes place, , text.

the method draws second frame located in 3rd class file, processing one, following:

public static void drawscenario(){ final jpanel mainpanel2 = new jpanel(); jpanel firstline = new jpanel(); jpanel secline = new jpanel(); mainpanel2.setlayout(new boxlayout(mainpanel2, boxlayout.y_axis)); mainpanel2.setborder(new emptyborder(new insets(5, 5, 5, 5))); mainpanel2.add(box.createverticalglue()); firstline.setlayout(new boxlayout(firstline, boxlayout.x_axis)); firstline.setborder(new emptyborder(new insets(5, 5, 5, 5))); firstline.add(box.createverticalglue()); secline.setlayout(new boxlayout(secline, boxlayout.x_axis)); secline.setborder(new emptyborder(new insets(5, 5, 5, 5))); secline.add(box.createverticalglue()); jtextarea textarea = new jtextarea("", 10, 40); textarea.setlinewrap(true); jscrollpane scrollpane = new jscrollpane(textarea); scrollpane.setverticalscrollbarpolicy(jscrollpane.vertical_scrollbar_always); textarea.seteditable(false); jlabel label1 = new jlabel("processing results:"); firstline.add(box.createrigidarea(new dimension(5,0))); firstline.add(label1); firstline.add(box.createrigidarea(new dimension(5,0))); secline.add(textarea); secline.add(box.createrigidarea(new dimension(5,0))); mainpanel2.add(firstline); mainpanel2.add(box.createrigidarea(new dimension(0, 30))); mainpanel2.add(secline); mainpanel2.add(box.createrigidarea(new dimension(0, 20))); jframe frame = new jframe("test results"); frame.setsize(400, 300); frame.setlocation(50,50); frame.setvisible( true ); frame.add(mainpanel2); frame.pack(); } 

the processing method ( public static void compare(string txt1, string txt2) ) located in same file, below drawscenario() method. question is, how print text compare() textarea of drawscenario() method?

also, window doesn't draw (it displays black column of sorts , doesn't draw textarea inside it) during processing although call drawscenario() before compare(). there way can fix that?

thank you!

as first question, let textarea instance variable instead. second, don't see wrong code have shown.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -