- import java.awt.BorderLayout;
- import java.awt.EventQueue;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import javax.swing.border.EmptyBorder;
- import javax.swing.JLabel;
- public class Main3 extends JFrame {
- private JPanel contentPane;
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- Main3 frame = new Main3();
- frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the frame.
- */
- public Main3() {
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setBounds(100, 100, 450, 300);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- contentPane.setLayout(null);
-
- Date d = new Date();
- SimpleDateFormat s1 = new SimpleDateFormat("yyyy/MM/dd a hh:mm:ss");
-
- JLabel lblNewLabel = new JLabel(s1.format(d));
- lblNewLabel.setBounds(142, 57, 336, 133);
- contentPane.add(lblNewLabel);
- }
- }
複製代碼 |