swing - java remote function need calling twice -
i've created java code (swing gui jframe form) phone call class function (which in project) when button pressed, needs me click button twice in order homecoming value called function. there solution?
here code,
the gui
package aarib; import java.awt.*; import java.util.logging.level; import java.util.logging.logger; import alkhalil.ui.aarib; public class gui extends javax.swing.jframe { public string input; public string lexems; public aarib a; public gui() { initcomponents(); = new aarib(); jtextfield1.setcomponentorientation(componentorientation.right_to_left); jlabel2.setcomponentorientation(componentorientation.right_to_left); } private void jbutton1actionperformed(java.awt.event.actionevent evt) { // todo add together handling code here: if(jtextfield1.gettext().isempty()) { jlabel2.settext("no input"); } else{ input = jtextfield1.gettext().tostring(); a.inputtext= input; seek { lexems = a.lexicalanalysis(); jlabel2.settext(lexems); } grab (exception ex) { jlabel2.settext("error"); logger.getlogger(gui.class.getname()).log(level.severe, null, ex); } } } }
and remote function
package alkhalil.ui; import java.util.*; import java.util.list; import alkhalil.token.*; import alkhalil.analyse.*; import alkhalil.*; import alkhalil.result.*; public class aarib { public analyzer analyzer; public string myresult=""; public string inputtext=""; public aarib() { settings settings = new settings(); analyzer = new analyzer(); } public string lexicalanalysis() throws exception { thread t = new thread() { public void run() { //some code ... ... ... } }; t.start(); homecoming myresult; } }
thanks in advance :)
the solution wait result produced in thread t. current code start concurrent thread , instantly homecoming attribute myresult. sec click on button myresult (most times) filled thread , returned after starting concurrent thread doing calculation.
i suggest considering kind of observer-pattern program. gui should obsever calculating thread , notified result, handled.
but cannot see code executed in thread , wait thread finish, why not not utilize thread.
java swing jframe remoteobject
No comments:
Post a Comment