展开全部
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Frame1 extends JFrame implements ActionListener {
JButton button;
Frame2 frame;
public Frame1(){
super("第一个窗口");
button=new JButton("点我");
button.addActionListener(this);
this.setSize(300,100);
this.add(button);
this.setLayout(new FlowLayout());
this.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==button){
frame=new Frame2();
}
}
public static void main(String[] args) {
new Frame1();
}
}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Frame2 extends JFrame implements ActionListener{
public Frame2(){
super("第二个窗口");
this.setSize(300,100);
this.setLayout(new FlowLayout());
this.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
}
}
两个文件哦 一个类放一个文件~
import java.awt.event.*;
import javax.swing.*;
public class Frame1 extends JFrame implements ActionListener {
JButton button;
Frame2 frame;
public Frame1(){
super("第一个窗口");
button=new JButton("点我");
button.addActionListener(this);
this.setSize(300,100);
this.add(button);
this.setLayout(new FlowLayout());
this.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==button){
frame=new Frame2();
}
}
public static void main(String[] args) {
new Frame1();
}
}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Frame2 extends JFrame implements ActionListener{
public Frame2(){
super("第二个窗口");
this.setSize(300,100);
this.setLayout(new FlowLayout());
this.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
}
}
两个文件哦 一个类放一个文件~
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询