- package bbs.istak.org.tw;
- import java.awt.BorderLayout;
- import java.awt.EventQueue;
- import java.util.Calendar;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import javax.swing.border.EmptyBorder;
- import javax.swing.JLabel;
- public class clock extends JFrame {
- private JPanel contentPane;
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- clock frame = new clock();
- frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the frame.
- */
- public clock() {
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setBounds(100, 100, 164, 128);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- contentPane.setLayout(null);
-
- JLabel lblNewLabel = new JLabel("New label");
- lblNewLabel.setBounds(10, 10, 128, 70);
- contentPane.add(lblNewLabel);
-
- Calendar c = Calendar.getInstance();
-
- SDF sdf = new SDF("yyyy/MM/dd hh:mm:ss");
- lblNewLabel.setText(sdf.format(c));
- }
- }
複製代碼 |