JAVA作业
来源:百度知道 编辑:UC知道 时间:2024/05/26 21:48:54
作业是女友的,我不会JAVA……谢谢
图贴不了……
//好象在Frame中作图比较麻烦,作图方法正在实现中………
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class GUI extends JFrame{
JButton SquareBtn;
JButton CircleBtn;
JButton TrangleBtn;
GUI(){
super();
}
GUI(String name){
super(name);
SquareBtn = new JButton("Square");
CircleBtn = new JButton("Circle");
TrangleBtn = new JButton("Trangle");
SquareBtn.addActionListener(new Command());
CircleBtn.addActionListener(new Command());
TrangleBtn.addActionListener(new Command());
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
setVisible(false);
dispose();
System.exit(0);
}
});
this.setLayout(new FlowLayout());
this.add(SquareBtn);
this.add(CircleBtn);
this.add(TrangleBtn);
this.setSize(300,100);
this.setVisible(true);