Swing Dialog Class won't wait ??
From: ralph (ralpht2_at_optonline.net)
Date: 03/30/05
- Next message: John McGrath: "Re: Wait cursor problem"
- Previous message: bilaribilari_at_yahoo.com: "Re: Wait cursor problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 29 Mar 2005 23:09:06 -0500
I am hoping that someone on this list can set me straight !!
I have an app (below) that calls a class containing a Swing JFrame. My
understanding is that swing starts its own java thread (which explains the
issue i am seeing).
How do I Call a class (of swing JFrame) to gather information and have the
caller "wait" for a return???? (BTW JDialog will not provide enough
functionality for this app).
You can see my (feable) test attempt below. Where am I off course ???
TIA !
------------------
import javax.swing.JDialog;
public class test_caller {
public static void main(String[] args) {
test aWin = new test();
aWin.show();
System.out.println("From caller userid="+aWin.userid);
}
}
----------------------
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JTextField;
public class test extends JFrame {
public String userid;
private javax.swing.JPanel jContentPane = null;
private JButton jButton = null;
private JTextField User = null;
/**
* This is the default constructor
*/
public test() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setName("Main_JFrame");
this.setSize(300,200);
this.setContentPane(getJContentPane());
this.setTitle("Tester");
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private javax.swing.JPanel getJContentPane() {
if(jContentPane == null) {
jContentPane = new javax.swing.JPanel();
jContentPane.setLayout(null);
jContentPane.add(getJButton(), null);
jContentPane.add(getUser(), null);
}
return jContentPane;
}
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setBounds(62, 90, 172, 63);
jButton.setText("Do It");
jButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
System.out.println("User="+User.getText());
userid = User.getText();
test.this.setVisible(false);
test.this.dispose();
return;
}
});
}
return jButton;
}
/**
* This method initializes jTextField
*
* @return javax.swing.JTextField
*/
private JTextField getUser() {
if (User == null) {
User = new JTextField();
User.setBounds(68, 23, 199, 35);
}
return User;
}
}
- Next message: John McGrath: "Re: Wait cursor problem"
- Previous message: bilaribilari_at_yahoo.com: "Re: Wait cursor problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]