java實習日記一

來源:互聯網
上載者:User
import java.awt.EventQueue;import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.border.EmptyBorder;import javax.swing.JButton;import javax.swing.JTextField;import javax.swing.JLabel;import java.awt.Color;import java.awt.SystemColor;import java.awt.event.ActionListener;import java.awt.event.ActionEvent;import java.awt.event.MouseAdapter;import java.awt.event.MouseEvent;public class Guess01 extends JFrame {    /**     *      */    private static final long serialVersionUID = 1L;        private JPanel contentPane;    private JTextField tfDir;    private JTextField tfClass;    /**     * Launch the application.     */    public static void main(String[] args) {        EventQueue.invokeLater(new Runnable() {            public void run() {                try {                    Guess01 frame = new Guess01();                    frame.setVisible(true);                } catch (Exception e) {                    e.printStackTrace();                }            }        });    }    /**     * Create the frame.     */    public Guess01() {        setTitle("\u731C\u731C\u770B\u6E38\u620FV0.1");        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        setBounds(100, 100, 645, 409);        contentPane = new JPanel();        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));        setContentPane(contentPane);        contentPane.setLayout(null);                // 選擇目錄 按鈕的處理常式        JButton btnDir = new JButton("\u9009\u62E9\u76EE\u5F55");        btnDir.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent arg0) {                            }        });        btnDir.setBounds(26, 26, 93, 23);        contentPane.add(btnDir);                // 文字框,顯示目錄        tfDir = new JTextField();        tfDir.setEditable(false);        tfDir.setBounds(125, 27, 363, 21);        contentPane.add(tfDir);        tfDir.setColumns(10);                // 選擇班級 按鈕的處理常式        JButton btnClass = new JButton("\u9009\u62E9\u73ED\u7EA7");        btnClass.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent e) {                            }        });        btnClass.setBounds(26, 59, 93, 23);        contentPane.add(btnClass);                // 文字框,顯示班級檔案        tfClass = new JTextField();        tfClass.setEditable(false);        tfClass.setBounds(125, 60, 363, 21);        contentPane.add(tfClass);        tfClass.setColumns(10);                // 標籤,顯示帶猜測學生姓名        JLabel lbGuessName = new JLabel("\u59D3\u540D");        lbGuessName.setBounds(259, 91, 102, 23);        contentPane.add(lbGuessName);                // 標籤,顯示第一個學生相片        JLabel lblImg1 = new JLabel("\u56FE\u72471");        lblImg1.addMouseListener(new MouseAdapter() {            @Override            public void mouseClicked(MouseEvent arg0) {                            }        });        lblImg1.setBounds(26, 151, 183, 178);        contentPane.add(lblImg1);                // 標籤,顯示第二個學生相片        JLabel lblImg2 = new JLabel("\u56FE\u72472");        lblImg2.addMouseListener(new MouseAdapter() {            @Override            public void mouseClicked(MouseEvent e) {                            }        });        lblImg2.setForeground(Color.BLACK);        lblImg2.setBackground(SystemColor.inactiveCaption);        lblImg2.setBounds(241, 155, 183, 172);        contentPane.add(lblImg2);                // 標籤,顯示第三個學生相片        JLabel lblImg3 = new JLabel("\u56FE\u72473");        lblImg3.addMouseListener(new MouseAdapter() {            @Override            public void mouseClicked(MouseEvent e) {                            }        });        lblImg3.setBounds(434, 155, 185, 172);        contentPane.add(lblImg3);                // 再猜一次 按鈕,點擊則更新相應的三張圖片 與 帶猜測學生姓名        JButton btnGuessAgain = new JButton("\u518D\u731C\u4E00\u6B21");        btnGuessAgain.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent e) {                            }        });        btnGuessAgain.setBounds(223, 337, 93, 23);        contentPane.add(btnGuessAgain);    }}




今天所完成的是認識猜猜看遊戲的大概代碼,查閱了所要實現目標的知識點 。為下面的各方面做準備

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.