⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nowtime.java

📁 用Java实现时钟
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. *//* * NowTime.java * * Created on 2009-5-9, 14:21:14 */package clock;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.text.SimpleDateFormat;import java.util.Date;/** * * @author Administrator */public class NowTime extends javax.swing.JPanel {    /** Creates new form NowTime */    public NowTime() {        initComponents();         final SimpleDateFormat t = new SimpleDateFormat("    kk:mm:ss");         int delay = 1000;       javax.swing.Timer timer = new javax.swing.Timer(delay, new ActionListener() {            public void actionPerformed(ActionEvent e) {                Date date1 = new Date();                tt.setText(t.format(date1));            }        });        timer.start();    }    /** This method is called from within the constructor to     * initialize the form.     * WARNING: Do NOT modify this code. The content of this method is     * always regenerated by the Form Editor.     */    @SuppressWarnings("unchecked")    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents    private void initComponents() {        tt = new javax.swing.JTextField();        tt.setFont(new java.awt.Font("楷体_GB2312", 1, 24)); // NOI18N        tt.setCaretColor(new java.awt.Color(255, 0, 51));        tt.setEnabled(false);        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);        this.setLayout(layout);        layout.setHorizontalGroup(            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addComponent(tt, javax.swing.GroupLayout.DEFAULT_SIZE, 242, Short.MAX_VALUE)        );        layout.setVerticalGroup(            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addComponent(tt, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 35, Short.MAX_VALUE)        );    }// </editor-fold>//GEN-END:initComponents    // Variables declaration - do not modify//GEN-BEGIN:variables    private javax.swing.JTextField tt;    // End of variables declaration//GEN-END:variables}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -