[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Java package: how to get output from a java gui
From: |
vinukn |
Subject: |
Re: Java package: how to get output from a java gui |
Date: |
Sat, 24 Nov 2012 17:12:34 -0800 (PST) |
import javax.swing.*;
public class MyFrame extends JFrame{
String text;
boolean isOk=false;
JTextField t;
public String getText(){
if(isOk){
return text;
else{
return "No text";
}
}
public void setText(String text){
this.text = text;
}
public void create(){
JFrame f = new JFrame();
JPanel p = new JPanel();
t = new JTextField(20);
JButton b = JButton("OK");
b.addActionListner(new ActionListner(){
public void actionPerformed(ActionEvent ae){
setText(t.getText());
isOk = true;
}
});
p.add(t);
p.add(b);
f.add(p);
f.setvisible(true);
}
public String octave_out(){
MyFrame m = new MyFrame();
m.create();
return m.getText();
}
}// end of code
I made a jar called myjar.jar. Then from octave terminal I create an object
pkg load java;
ob=javaObject('MyFrame');
ob.octave_out()
octave displayed gui and return a text "No text". Gui does not wait for user
input.
--
View this message in context:
http://octave.1599824.n4.nabble.com/Java-package-how-to-get-output-from-a-java-gui-tp4647054p4647077.html
Sent from the Octave - General mailing list archive at Nabble.com.