物件Object
實際做出例子 實例來自於類別
類別Class
屬性property
事件event
方法method(V.)
行為behavior(V.)
import java.awt.event.*;
public class Exe extends JFrame implements ActionListener {
int SizeW = 1210;
int SizeH = 1170;
public static void main(String[] args) {
Exe test = new Exe();
}
public Exe() {
setTitle("YJF"); // 設定視窗標題
JButton mybutton = new JButton("楊");
JButton mybutton1 = new JButton("政");
JCheckBox CB = new JCheckBox("wwwww");
JRadioButton RB = new JRadioButton("OO");
mybutton.addActionListener(this);
getContentPane().add(mybutton);
getContentPane().add(mybutton1);
getContentPane().add(RB);
getContentPane().add(CB);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(512,512);
mybutton.setBounds(300,300,100,100);
mybutton1.setBounds(110,110,100,100);
setVisible(true);
CB.setSize(200, 100);
RB.setSize(200, 100);
}
public void actionPerformed(ActionEvent e) {
SizeW = SizeW * 2;
SizeH = SizeH * 2;
setSize(SizeW,SizeH);
}
}
沒有留言:
張貼留言