1,.在java中如何在一个窗口Frame1里,调用另一个窗口Frame2,在Frame2出来后关闭窗口Frame1,请给一个具体
1个回答
展开全部
public class Test {
C1 c1;
C2 c2;
public static void main(String args[])
{
new C1();
}
}
class C1 extends JFrame implements ActionListener{
public C1() throws HeadlessException {
JButton b = new JButton("hheh");
this.add(b);
b.addActionListener(this);
this.setBounds(400,360,200, 300);
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent ae) {
this.dispose();
new C2();
}
}
class C2 extends JFrame{
public C2() throws HeadlessException {
this.add(new JLabel("i am a label"));
this.setBounds(400, 360,40,60);
this.setVisible(true);
}
}
自己写的,经过调试的,肯定正确
C1 c1;
C2 c2;
public static void main(String args[])
{
new C1();
}
}
class C1 extends JFrame implements ActionListener{
public C1() throws HeadlessException {
JButton b = new JButton("hheh");
this.add(b);
b.addActionListener(this);
this.setBounds(400,360,200, 300);
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent ae) {
this.dispose();
new C2();
}
}
class C2 extends JFrame{
public C2() throws HeadlessException {
this.add(new JLabel("i am a label"));
this.setBounds(400, 360,40,60);
this.setVisible(true);
}
}
自己写的,经过调试的,肯定正确
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询