class DlgMain extends JDialog {
JButton btn = new JButton("create");
public DlgMain() {
this.getContentPane().add(btn);
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
DlgKid xx1 = new DlgKid();
xx1.setVisible(true);
}
});
this.show();
}
public static void main(String[] args) {
DlgMain xx = new DlgMain();
xx.setSize(200,200);
xx.pack(); }
}
class DlgKid extends JDialog {
JButton btn = new JButton("kill me");
DlgKid handle;
public DlgKid() {
this.getContentPane().add(btn);
this.setSize(100,100);
this.setLocation(200,200);
handle = this;
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handle.dispose();
}
});
pack();
}
}
JButton btn = new JButton("create");
public DlgMain() {
this.getContentPane().add(btn);
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
DlgKid xx1 = new DlgKid();
xx1.setVisible(true);
}
});
this.show();
}
public static void main(String[] args) {
DlgMain xx = new DlgMain();
xx.setSize(200,200);
xx.pack(); }
}
class DlgKid extends JDialog {
JButton btn = new JButton("kill me");
DlgKid handle;
public DlgKid() {
this.getContentPane().add(btn);
this.setSize(100,100);
this.setLocation(200,200);
handle = this;
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handle.dispose();
}
});
pack();
}
}
JButton btn = new JButton("create child");
DlgKid xx1;
public DlgMain() {
this.getContentPane().add(btn);
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(btn.getText().indexOf("create") != -1) {
xx1 = new DlgKid();
xx1.setVisible(true);
btn.setText("kill child");
}else {
btn.setText("create child");
xx1.dispose();
}
}
});
this.show();
}
public static void main(String[] args) {
DlgMain xx = new DlgMain();
xx.setSize(200,200);
xx.pack(); }
}
class DlgKid extends JDialog {
JButton btn = new JButton("kill me");
DlgKid handle;
public DlgKid() {
this.getContentPane().add(btn);
this.setSize(100,100);
this.setLocation(200,200);
handle = this;
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handle.dispose();
}
});
pack();
}
}