java - How to transfer outputs of methods to the dialog boxes? -


try {         project.firebuildstarted();         project.init();         projecthelper projecthelper = projecthelper.getprojecthelper();         project.addreference("ant.projecthelper", projecthelper);         projecthelper.parse(project, buildfile);          // if no target specified default target executed.         string targettoexecute = (target != null && target.trim().length() > 0) ? target                 .trim() : project.getdefaulttarget();         project.executetarget(targettoexecute);         project.firebuildfinished(null);         success = true;      } catch (buildexception buildexception) {         project.firebuildfinished(buildexception);         joptionpane.showmessagedialog(null, buildexception, "warning",                 joptionpane.warning_message);         throw new runtimeexception(                 "!!! unable restart iehs app !!!", buildexception);      } 

above methods giving output on console, need them in dialog boxes. how can ?

i think trying capture console logs ui component, if case, here sample create output stream , capture console output , show in ui component. can try this.

public class console extends jdialog { jtextarea textarea = null; /**  * launch application.  */ public static void main(string[] args) {     try {         console dialog = new console();         dialog.setdefaultcloseoperation(jdialog.dispose_on_close);         dialog.setvisible(true);     } catch (exception e) {         e.printstacktrace();     } }  private void updatetextpane(final string text) {     swingutilities.invokelater(new runnable() {          public void run() {             textarea.append(text);            }     }); }  /**  * create dialog.  */ public console() {      //creating stream move consle output else     outputstream out = new outputstream() {          @override         public void write(final int b) throws ioexception {             updatetextpane(string.valueof((char) b));         }          @override         public void write(byte[] b, int off, int len) throws ioexception {             updatetextpane(new string(b, off, len));         }          @override         public void write(byte[] b) throws ioexception {             write(b, 0, b.length);         }     };      system.setout(new printstream(out, true));     system.seterr(new printstream(out, true));      setbounds(100, 100, 450, 300);     getcontentpane().setlayout(null);      jbutton btnnewbutton = new jbutton("new button");     btnnewbutton.addactionlistener(new actionlistener() {         public void actionperformed(actionevent e) {             system.out.println("hello");         }     });     btnnewbutton.setbounds(91, 192, 91, 23);     getcontentpane().add(btnnewbutton);      textarea = new jtextarea();     textarea.setbounds(30, 11, 241, 136);     getcontentpane().add(textarea); } } 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -