JAVA窗口问题有两个窗口A,B
试试这个:
import t。event。ActionEvent;
import t。event。ActionListener;
import javax。swing。JButton;
import javax。 swing。JFrame;
public class A extends JFrame {
private JButton open = new JButton("open");
private B b = new B();
private A() {
super("Main Window");
tContentPane()。 add(open);
tSize(300, ...全部
试试这个:
import t。event。ActionEvent;
import t。event。ActionListener;
import javax。swing。JButton;
import javax。
swing。JFrame;
public class A extends JFrame {
private JButton open = new JButton("open");
private B b = new B();
private A() {
super("Main Window");
tContentPane()。
add(open);
tSize(300, 300);
tDefaultCloseOperation(JFrame。EXIT_ON_CLOSE);
tVisible(true);
dActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
tVisible(true);
}
});
}
public static void main(String[] args) {
A a = new A();
ck();
}
}
class B extends JFrame {
private JButton close = new JButton("close");
public B() {
super("Sub Window");
tSize(200, 200);
tVisible(false);
tContentPane()。
add(close);
dActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
closeWindow();
}
});
tDefaultCloseOperation(JFrame。
DISPOSE_ON_CLOSE);
ck();
}
private void closeWindow() {
this。dispose();
}
}
。收起