?? mvc2view.java
字號:
package com.sitinspring;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Toolkit;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
/**
* 視圖類(View)
*
* @author sitinspring(junglesong@gmail.com)
*
* @date 2007-11-5
*/
public class Mvc2View extends JFrame {
private static final long serialVersionUID = 621145935910133202L;
private JButton button;
private JLabel label;
private JButton button2;
private JLabel label2;
public Mvc2View() {
locateView(300, 200);
this.setTitle("MVC2 Program");
setupComponents();
this.setVisible(true);
}
// 定位程序在屏幕正中并設置程序大小
private void locateView(int width, int height) {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
this.setSize(width, height);
this.setLocation(screenSize.width / 2 - width / 2, screenSize.height
/ 2 - height / 2);
}
// 初始化內部組件
private void setupComponents() {
button = new JButton("點擊響應事件1");
label = new JLabel(" 等待事件響應1");
button2 = new JButton("點擊響應事件2");
label2 = new JLabel(" 等待事件響應2");
setLayout(new GridLayout(2, 2));
add(button);
add(label);
add(button2);
add(label2);
}
public JButton getButton() {
return button;
}
public JButton getButton2() {
return button2;
}
public JLabel getLabel() {
return label;
}
public JLabel getLabel2() {
return label2;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -