How it works?
- Class MiWindows is responsible for running the class MiOtherWindows.
- MiOtherWindows class interacts with the user who changes their status and closes.
- Class MiWindows detects the change of value in the class MiOtherWindows.
- The Class MiWindows prints out the changes.
What is the Problem? MiWIndows class does not detect the change in the child class MiOtherWindows.
Question?
How to make a window I can listen to another without using threads?
//-------------------------------------------------------------------
//HERE IS THE CODE OF MiWindows
public class MiWindows extends JDialog {
private JButton doing = new JButton("The Button");
public MiWindows(SeconWindows owner) {
doing.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Object value;
try {
value = new MiOtherWindows(MiWindows.this).getValue();
if (value != null) {
System.out.println("Never Print this...");
}
} catch (Exception x) {
System.out.println("exception");
}
}
});
}
}
//-------------------------------------------------------------------
//HERE IS THE CODE OF MiOtherWindows
public class MiOtherWindows extends JDialog {
private JButton close = new JButton("The Button");
private String value = null;
public MiOtherWindows(JDialog owner) {
super(owner);
//super(owner, true); modal don't work
close.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
this.value = "This is Result";
setVisible(false);
}
});
}
public String getValue() {
return value;
}
}