zoukankan      html  css  js  c++  java
  • swing时钟

    import java.awt.*;
    import java.util.*;
    import javax.swing.*;
    public class HyClock extends JFrame implements Runnable {
        public static JLabel tm;
        public void run() {
            while (true) {
                Calendar c = Calendar.getInstance();
                String nowtime = c.get(Calendar.HOUR_OF_DAY) + ":" + c.get(Calendar.MINUTE) + ":" + c.get(Calendar.SECOND);
                tm.setText(nowtime);
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                }
            }
        }
     
        public static void main(String[] agrs) {
            HyClock  hytime = new HyClock();
            hytime.setLayout(new FlowLayout());
            tm = new JLabel();
            tm.setFont(new Font("宋体", 1, 40));
            tm.setForeground(Color.RED);
            hytime.add(tm);
            hytime.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
            hytime.setSize(300, 100);
            hytime.setVisible(true);
            hytime.setLocation(400, 400);
            Thread t = new Thread(hytime);
            t.start();
        }
    }
    import java.awt.*;
    import java.util.*;
    import javax.swing.*;
    public class HyClock extends JFrame implements Runnable {
        public static JLabel tm;
        public void run() {
            while (true) {
                Calendar c = Calendar.getInstance();
                String nowtime = c.get(Calendar.HOUR_OF_DAY) + ":" + c.get(Calendar.MINUTE) + ":" + c.get(Calendar.SECOND);
                tm.setText(nowtime);
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                }
            }
        }
     
        public static void main(String[] agrs) {
            HyClock  hytime = new HyClock();
            hytime.setLayout(new FlowLayout());
            tm = new JLabel();
            tm.setFont(new Font("宋体", 1, 40));
            tm.setForeground(Color.RED);
            hytime.add(tm);
            hytime.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
            hytime.setSize(300, 100);
            hytime.setVisible(true);
            hytime.setLocation(400, 400);
            Thread t = new Thread(hytime);
            t.start();
        }
    }
  • 相关阅读:
    LightOJ 1132 Summing up Powers(矩阵快速幂)
    hdu 3804 Query on a tree (树链剖分+线段树)
    LightOJ 1052 String Growth && uva 12045 Fun with Strings (矩阵快速幂)
    uva 12304 2D Geometry 110 in 1! (Geometry)
    LA 3263 That Nice Euler Circuit (2D Geometry)
    2013 SCAUCPC Summary
    poj 3321 Apple Tree (Binary Index Tree)
    uva 11796 Dog Distance (几何+模拟)
    uva 11178 Morley's Theorem (2D Geometry)
    动手动脑
  • 原文地址:https://www.cnblogs.com/a709898670/p/9455607.html
Copyright © 2011-2022 走看看