help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Java package: how to get output from a java gui


From: Michael Goffioul
Subject: Re: Java package: how to get output from a java gui
Date: Sun, 25 Nov 2012 10:35:05 -0500

On Sat, Nov 24, 2012 at 8:12 PM, vinukn <address@hidden> wrote:
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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]