📄 showtime.java
字号:
package gongju;
import java.awt.BorderLayout;
import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;
import javax.swing.JPanel;
import javax.swing.JTextPane;
/**
* This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
* Builder, which is free for non-commercial use. If Jigloo is being used
* commercially (ie, by a corporation, company or business for any purpose
* whatever) then you should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details. Use of Jigloo implies
* acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
* PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
* ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
// 显示时间的中间控件
public class Showtime extends JPanel implements Runnable {
Thread Timetr;
GregorianCalendar gcalendar;
public JTextPane jTextPane1;
public Showtime() {
initGUI();
Timetr = new Thread(this);
Timetr.start();
}
public void run() {
while (Timetr != null) {
display();
try {
Timetr.sleep(1000);
} catch (InterruptedException e) {
System.out.print(e);
}
}
}
private void display() {
java.util.Date date = (new GregorianCalendar()).getTime();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd\nHH:mm:ss");
jTextPane1.setText(format.format(date));
}
public void stop() {
Timetr.stop();
}
private void initGUI() {
setVisible(true);
BorderLayout thisLayout = new BorderLayout();
this.setLayout(thisLayout);
this.setPreferredSize(new java.awt.Dimension(161, 30));
{
jTextPane1 = new JTextPane();
this.add(jTextPane1, BorderLayout.CENTER);
jTextPane1.setPreferredSize(new java.awt.Dimension(230, 72));
jTextPane1.setEditable(false);
// jTextPane1.setFont(new java.awt.Font("Tahoma",0,16));
}
{
this.setSize(230, 114);
}
}
public static void main(String args[]) {
new Showtime();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -