timedialog.java
来自「Eclipse编程技术与实例一书的附CD-ROM光盘」· Java 代码 · 共 35 行
JAVA
35 行
package myplugin;
import java.util.Date;
import javax.swing.JDialog;
import javax.swing.JEditorPane;
public class TimeDialog extends JDialog {
private JEditorPane jEditorPane = null;
public TimeDialog() {
initialize();
}
// 在TimeDialog上添加JEditorPane,并显示出当前的时间、日期
private void initialize() {
this.setContentPane(getJEditorPane());
this.jEditorPane.setText(new Date().toString());
this.jEditorPane.setEditable(false); // 不允许编辑
this.setTitle("时间日期"); // 设定标题
this.setSize(200, 200); // 设定显示大小
}
// 初始化JEditorPane
private JEditorPane getJEditorPane() {
if (jEditorPane == null) {
jEditorPane = new JEditorPane();
}
return jEditorPane;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?