返回列表 發帖
  1. import java.awt.BorderLayout;
  2. import java.awt.EventQueue;
  3. import java.text.SimpleDateFormat;
  4. import java.util.Date;

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


  9. public class Main3 extends JFrame {

  10.         private JPanel contentPane;

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

  26.         /**
  27.          * Create the frame.
  28.          */
  29.         public Main3() {
  30.                 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  31.                 setBounds(100, 100, 450, 300);
  32.                 contentPane = new JPanel();
  33.                 contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  34.                 setContentPane(contentPane);
  35.                 contentPane.setLayout(null);
  36.                
  37.                 Date d = new Date();
  38.                 SimpleDateFormat s1 = new SimpleDateFormat("yyyy/MM/dd a hh:mm:ss");
  39.                
  40.                 JLabel lblNewLabel = new JLabel(s1.format(d));
  41.                 lblNewLabel.setBounds(142, 57, 336, 133);
  42.                 contentPane.add(lblNewLabel);
  43.         }
  44. }
複製代碼

TOP

返回列表