【连阳指标源码】【rasa源码讲解】【党建超市源码】猜喜欢源码_猜你喜欢代码

时间:2024-12-29 01:15:23 来源:源码网wlxiu 编辑:happytime onvif源码

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

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

急求猜数字小游戏代码

       本人是猜喜JAVA语言爱好者,赠送你我的欢源连阳指标源码源码。

       还是码猜rasa源码讲解学学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,喜欢党建超市源码,,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