想自己做个程序,望大侠帮帮忙!!!
第1个回答 2010-11-07
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) {
}
}
两个文件哦 一个类放一个文件~本回答被提问者采纳