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

📄 e_clock.java

📁 Programm that represents digital clock
💻 JAVA
字号:


package clock;
import java.awt.*;
import java.util.Calendar;
import java.util.Date;
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;


public class e_clock extends JFrame{
     
    JLabel Label_Time;
    /** Creates a new instance of e_clock */
    public e_clock() {
        
        Container container = getContentPane();
        container.setLayout( new FlowLayout());
        Label_Time = new JLabel();
        Date dt;
        dt=new Date(System.currentTimeMillis());
        
String str;

long hours=dt.getHours();
long minutes=dt.getMinutes();
long seconds=dt.getSeconds();

//Calendar cal; 
//cal.getInstance();
//str=Integer.toString(cal.get(Calendar.HOUR));

str=Long.toString(hours)+":"+Long.toString(minutes)+":"+Long.toString(seconds);

 
        Label_Time.setText(str);
             container.add(Label_Time);
        setSize(260,180);

        setVisible(true);
   
   //   System.currentTimeMillis();
       
    }
    
    public void tick()
    {Date dt;
        dt=new Date(System.currentTimeMillis());
        
String str;

long hours=dt.getHours();
long minutes=dt.getMinutes();
long seconds=dt.getSeconds();

//Calendar cal; 
//cal.getInstance();
//str=Integer.toString(cal.get(Calendar.HOUR));

str=Long.toString(hours)+":"+Long.toString(minutes)+":"+Long.toString(seconds);

 
        Label_Time.setText(str);
    }
    
}

⌨️ 快捷键说明

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