JAVA-手机日期和时间

image

package com.itheima;

import javax.swing.*;

public class JFrame08 {
    public static void main(String[] args) {
        JFrame jf=new JFrame();
        jf.setTitle("猜数字游戏");
        jf.setSize(400,300);
        jf.setDefaultCloseOperation(3);
        jf.setLocationRelativeTo(null);
        jf.setAlwaysOnTop(true);
        jf.setLayout(null);        //取消窗体的默认布局


        //提示日期
        JLabel dataLable=new JLabel("日期");
        dataLable.setBounds(50,50,100,20);
        jf.add(dataLable);

        //按照格式显示日期的字符串
        JLabel showDateLable=new JLabel("xxxx年xx月xx日");
        showDateLable.setBounds(50,80,200,20);
        jf.add(showDateLable);

        //提示时间
        JLabel timeLable = new JLabel("时间");
        timeLable.setBounds(50,150,100,20);
        jf.add(timeLable);

        //按照格式显示时间的字符串
        JLabel showtimeLable = new JLabel("xx:xx");
        showtimeLable.setBounds(50,180,200,20);
        jf.add(showtimeLable);










        //添加按钮到窗体中
        jf.setVisible(true);


    }
}

image

posted @ 2022-10-29 22:55  NiceTwocu  阅读(34)  评论(0编辑  收藏  举报