一个窗口关闭时,另一个窗口打开.import java.awt.*;
import java.awt.event.*;
class Frame1 extends Frame
{ p1 a;
Frame1(String s)
{ super(s);
a=new p1();
addWindowListener(a);
setBounds(100,100,200,300);
setVisible(true);
validate();
}
}
class Frame2 extends Frame
{ p2 b;
Frame2(String s)
{ super(s);
b=new p2();
addWindowListener(b);
setBounds(100,100,200,300);
setVisible(true);
validate();
}
}
class p1 extends WindowAdapter
{
Frame1 f1;Frame2 f2;
public void windowClosing(WindowEvent e)
{ System.exit(0);
}
public void windowClosed(WindowEvent e)
{ f2.setVisible(true);
f2.validate();
}
}
class p2 extends WindowAdapter
{
Frame1 f1;Frame2 f2;
public void windowClosing(WindowEvent e)
{ f2.setVisible(false);
f1.setVisible(true);
f1.validate();
} }public class z
{ public static void main(String args[])
{ Frame1 f1= new Frame1("窗口1");Frame2 f2=new Frame2("窗口2");
}
}
import java.awt.event.*;
class Frame1 extends Frame
{ p1 a;
Frame1(String s)
{ super(s);
a=new p1();
addWindowListener(a);
setBounds(100,100,200,300);
setVisible(true);
validate();
}
}
class Frame2 extends Frame
{ p2 b;
Frame2(String s)
{ super(s);
b=new p2();
addWindowListener(b);
setBounds(100,100,200,300);
setVisible(true);
validate();
}
}
class p1 extends WindowAdapter
{
Frame1 f1;Frame2 f2;
public void windowClosing(WindowEvent e)
{ System.exit(0);
}
public void windowClosed(WindowEvent e)
{ f2.setVisible(true);
f2.validate();
}
}
class p2 extends WindowAdapter
{
Frame1 f1;Frame2 f2;
public void windowClosing(WindowEvent e)
{ f2.setVisible(false);
f1.setVisible(true);
f1.validate();
} }public class z
{ public static void main(String args[])
{ Frame1 f1= new Frame1("窗口1");Frame2 f2=new Frame2("窗口2");
}
}
{
Frame1 f1;Frame2 f2;
public void windowClosing(WindowEvent e)
{ f1.dispose();
}
public void windowClosed(WindowEvent e)
{ f2.setVisible(true);
f2.validate();
}
}
import java.awt.event.*;class Frame1 extends Frame {
Frame1(String s) {
super(s);
setBounds(100, 100, 200, 300);
validate();
}
}class Frame2 extends Frame {
Frame2(String s) {
super(s);
setBounds(100, 100, 200, 300);
validate();
}
}class p1 extends WindowAdapter {
Frame1 f1;
Frame2 f2; public p1(Frame1 f1, Frame2 f2) {
this.f1 = f1;
this.f2 = f2;
} public void windowClosing(WindowEvent e) {
f1.setVisible(false);
f2.setVisible(true);
f2.validate();
} public void windowClosed(WindowEvent e) { }
}class p2 extends WindowAdapter {
Frame1 f1;
Frame2 f2; public p2(Frame1 f1, Frame2 f2) {
this.f1 = f1;
this.f2 = f2;
} public void windowClosing(WindowEvent e) {
f2.setVisible(false);
f1.setVisible(true);
f1.validate();
}
}public class z {
public static void main(String args[]) {
Frame1 f1 = new Frame1("窗口1");
Frame2 f2 = new Frame2("窗口2"); p1 a = new p1(f1, f2);
p2 b = new p2(f1, f2);
f1.addWindowListener(a);
f2.addWindowListener(b); f1.setVisible(true);
}
}要这个有什么用啊