information.java

来自「本程序不仅实现了记事本基本的功能」· Java 代码 · 共 68 行

JAVA
68
字号
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package jnotepad;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.text.DateFormat;import java.util.Date;import javax.swing.*;/** * * @author Administrator */class Information extends JFrame implements Runnable {    public Information(Frame owner) {        this.setTitle("记事本");        icon.setBounds(25,10,100,100);        name.setBounds(128, 10, 100, 20);        version.setBounds(128,45,150,20);        Date d = new Date();        String str = DateFormat.getDateTimeInstance().format(d);        date = new JLabel("当前时间:" + str);        date.setBounds(128, 80, 200, 30);        jok = new JButton("确  定");        jok.setBounds(25,130, 80, 30);        jok.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent e) {                thread.stop();                Information.this.dispose();            }        });		setSize(owner.getWidth(),owner.getHeight());        setLayout(null);                add(icon);        add(name);        add(version);        add(date);        add(jok);        setBounds(owner.getBounds());        setResizable(false);        thread.start();        setVisible(true);    }    private JButton jok;    private JLabel icon = new JLabel(new ImageIcon("smile.gif"));    private JLabel version = new JLabel("版    本:奶牛摩托1.0版本");    private JLabel name = new JLabel("作    者:卢 成 彪");    private JLabel date;    private Thread thread = new Thread(this);    public void run() {        while(true)        {         Date d = new Date();         String str = DateFormat.getDateTimeInstance().format(d);         date.setText("当前时间:" + str);        }    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?