行业知识
Flip Clock(not good)
2026-11-13 05:18:09
来源:互联网转载
���近体验了一下iOS的翻页时钟app,很想自己做一个,但是效果不好
public class main { public static void main(String[] args) { //psvm new MyFrame(); }}
import javax.swing.*;import java.awt.*;import java.io.File;import java.io.IOException;import java.text.Format;import java.text.SimpleDateFormat;import java.util.Calendar;import java.util.Locale;import java.util.SimpleTimeZone;public class MyFrame extends JFrame { Calendar calendar; SimpleDateFormat timeFormat; SimpleDateFormat dayFormat; SimpleDateFormat dateFormat; JLabel timeLabel; JLabel dayLabel; JLabel dateLabel; String time; String day; String date; MyFrame(){ this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //设置默认关闭操作jframe点退出关闭 this.setTitle("My Clock Program"); this.setLayout(new FlowLayout()); this.setSize(350,200); this.setResizable(false); timeFormat = new SimpleDateFormat("hh:mm:ss a",Locale.CHINESE);//kk dayFormat = new SimpleDateFormat("EEEE",Locale.CHINESE); dateFormat = new SimpleDateFormat("MMMMM dd,yyyy", Locale.CHINESE); timeLabel = new JLabel(); timeLabel.setFont(new Font("Verdana",Font.PLAIN,50)); timeLabel.setForeground(new Color(0x00FF00)); timeLabel.setBackground(Color.black); timeLabel.setOpaque(true); dayLabel = new JLabel(); dayLabel.setFont(new Font("Arial", Font.PLAIN, 35)); dateLabel = new JLabel(); dateLabel.setFont(new Font("Verdana",Font.PLAIN,25)); this.add(timeLabel); this.add(dayLabel); this.add(dateLabel); this.setVisible(true); setTime(); } public void setTime() { while(true){ time = timeFormat.format(Calendar.getInstance().getTime()); timeLabel.setText(time); day = dayFormat.format(Calendar.getInstance().getTime()); dayLabel.setText(day); date = dateFormat.format(Calendar.getInstance().getTime()); dateLabel.setText(date); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } }} 这个方框里面的不知道为什么不能正确显示
下一篇:广告服务器功能介绍怎么写?