?? annotationtest.java
字號:
import javax.swing.*;
import java.awt.event.*;
/**
* Description:
* <br/>Copyright (C), 2005-2008, Yeeku.H.Lee
* <br/>This program is protected by copyright laws.
* <br/>Program Name:
* <br/>Date:
* @author Yeeku.H.Lee kongyeeku@163.com
* @version 1.0
*/
public class AnnotationTest
{
private JFrame mainWin = new JFrame("使用注釋綁定事件監聽器");
//使用注釋為ok按鈕綁定事件監聽器
@ActionListenerFor(listener="OkListener")
private JButton ok = new JButton("確定");
//使用注釋為cancel按鈕綁定事件監聽器
@ActionListenerFor(listener="CancelListener")
private JButton cancel = new JButton("取消");
public void init()
{
//初始化界面的方法
JPanel jp = new JPanel();
jp.add(ok);
jp.add(cancel);
mainWin.add(jp);
ActionListenerInstaller.processAnnotations(this);
mainWin.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainWin.pack();
mainWin.setVisible(true);
}
public static void main(String[] args)
{
new AnnotationTest().init();
}
}
class OkListener implements ActionListener
{
public void actionPerformed(ActionEvent evt)
{
JOptionPane.showMessageDialog(null , "單擊了確認按鈕");
}
}
class CancelListener implements ActionListener
{
public void actionPerformed(ActionEvent evt)
{
JOptionPane.showMessageDialog(null , "單擊了取消按鈕");
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -