返回列表 發帖
  1. package tw.kuas.edu.tw;

  2. import java.awt.BorderLayout;
  3. import java.awt.EventQueue;

  4. import javax.swing.JFrame;
  5. import javax.swing.JPanel;
  6. import javax.swing.border.EmptyBorder;
  7. import javax.swing.JLabel;

  8. import java.awt.Toolkit;
  9. import java.awt.Font;
  10. import java.text.SimpleDateFormat;
  11. import java.util.Date;
  12. import java.awt.Color;

  13. public class CTime extends JFrame {

  14.         private JPanel contentPane;

  15.         /**
  16.          * Launch the application.
  17.          */
  18.         public static void main(String[] args) {
  19.                 EventQueue.invokeLater(new Runnable() {
  20.                         public void run() {
  21.                                 try {
  22.                                         CTime frame = new CTime();
  23.                                         frame.setVisible(true);
  24.                                 } catch (Exception e) {
  25.                                         e.printStackTrace();
  26.                                 }
  27.                         }
  28.                 });
  29.         }

  30.         /**
  31.          * Create the frame.
  32.          */
  33.         public CTime() {
  34.                 setIconImage(Toolkit.getDefaultToolkit().getImage(CTime.class.getResource("/tw/kuas/edu/tw/59252.png")));
  35.                 setTitle("CLOCK");
  36.                 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  37.                 setBounds(100, 100, 513, 100);
  38.                 contentPane = new JPanel();
  39.                 contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  40.                 setContentPane(contentPane);
  41.                 contentPane.setLayout(null);
  42.                
  43.                 JLabel label = new JLabel("");
  44.                 label.setForeground(Color.RED);
  45.                 label.setFont(new Font("Consolas", Font.BOLD, 48));
  46.                 label.setBounds(0, 0, 519, 62);
  47.                 contentPane.add(label);
  48.                 Date time = new Date();
  49.         SimpleDateFormat sdt1 = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
  50.         label.setText(sdt1.format(time));
  51.                        
  52.         }
  53. }
複製代碼

TOP

返回列表