欢迎访问皮皮网官网
皮皮网

【家用私有云源码】【源码精灵小布丁】【git求职平台源码】猜喜欢源码_猜你喜欢代码

时间:2024-11-25 01:47:30 分类:娱乐 来源:大盘和个股rsi指标源码

1.急求猜数字小游戏代码

猜喜欢源码_猜你喜欢代码

急求猜数字小游戏代码

       本人是猜喜JAVA语言爱好者,赠送你我的欢源家用私有云源码源码。

       还是码猜源码精灵小布丁学学JAVA吧。

       import java.awt.*;

       import javax.swing.*;

       import java.awt.event.*;

       import javax.swing.event.*;

       class Guess extends JFrame implements ActionListener{

        int rand;

        JLabel label = new JLabel("Enter whole number:");

        JLabel label_image = new JLabel( new ImageIcon(".gif"));

        JTextField textfield = new JTextField();

        JButton button_guess = new JButton("Guess");

        JButton button_again = new JButton("Once again");

        JPanel panel_north = new JPanel();

        JPanel panel_center = new JPanel();

        JPanel panel_north_middle = new JPanel();

        TextArea textarea = new TextArea(null,喜欢git求职平台源码,,TextArea.SCROLLBARS_BOTH);

        //---------------------------------------

        Guess(){

        this.setSize(,);

        this.rand=(int)(Math.random()*);

        Container face =this.getContentPane();

        face.add(panel_north,"North");

        face.add(panel_center);

        panel_north.setLayout(new GridLayout(1,3,3,1));

        panel_north.add(label);

        panel_north.add(textfield);

        panel_north.add(button_guess);

        panel_north.add(button_again);

        panel_center.add(textarea);

        panel_center.add(label_image);

        button_guess.addActionListener(this);

        button_again.addActionListener(this);

        this.setVisible(true);

        }

        //---------------------------------------------

        public void actionPerformed(ActionEvent w){

        try{

        if(w.getSource()==button_guess){

        String s=textfield.getText();

        int x=Integer.parseInt(s);

        if(x==rand){

        textarea.append("Congratulate!\n");

        }

        else if(x>rand){

        textarea.append("The number on the height side!\n");

        }

        else if(x<rand){

        textarea.append("The number on the low side!\n");

        }

        textfield.setText("");

        textfield.requestFocusInWindow();

        }

        else if(w.getSource()==button_again){

        textarea.setText("");

        rand=(int)(Math.random()*);

        }

        }catch(Exception e){ }

        }

       //-----------------------------------------------------------

        public static void main(String arg[]){

        new Guess().setDefaultLookAndFeelDecorated(true);

        }

        }

copyright © 2016 powered by 皮皮网   sitemap