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.
AFAICS there's nothing in the octave_out code to make it wait until the dialog is closed. You would get the same behavior in plain Java. What you probably need is to create a modal JDialog to make show() or setVisible(true) blocking.
Michael.