//import javax.swing.*;
import java.awt.*;
import java.awt.event.*; // 要處理事件必須 import 此套件
public class Work2 extends Frame
implements ActionListener
{
/**
* @param args
*/
//int act = 0; // 用來記錄按鈕被次數的變數
int SizeW = 2100;
int SizeH = 700;
public static void main(String[] args)
{
//Work2 test = new Work2();
Frame frame= new Frame("Checkbox");
Checkbox check=new Checkbox("4");
frame.add(check);
Checkbox check1=new Checkbox("3");
frame.add(check1);
// Frame frame=new Frame("Button Frame");
Button button1 = new Button("2");
frame.add(button1);
frame.setLayout(new FlowLayout());
Button button2 = new Button("1");
frame.add(button2);
frame.setLayout(new FlowLayout());
frame.setSize(600,300);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
// 用建構方法來建立元件、將元件加入視窗、顯示視窗
//public Work2()
{
//setTitle("Listener 示範"); // 設定視窗標題
//JButton mybutton = new JButton("換個標題");
// 通知按鈕物件:本物件要當傾聽者
//mybutton.addActionListener(this);
//getContentPane().add(mybutton);
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//setSize(SizeW,SizeH);
//setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
//SizeW = (int) (SizeW * 0.5);
//SizeH = (int) (SizeH * 0.5);
//setSize(SizeW,SizeH);
}
}
沒有留言:
張貼留言