阅读背景:

JAVA - 类和它的对象,超级

来源:互联网 

This is the class Gui.

这是班贵。

import java.awt.BorderLayout;
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JButton;

public class Gui extends JFrame{
    Principal obiect;
    public JButton heads = new JButton("Heads");
    public JButton tails = new JButton("Tails");
    public static JTextField display;
    public JTextField comboul;
    public JPanel panel = new JPanel();
    public int predictie;


    public Gui(){
        super("HeadsOrTails");
        panel.setLayout(new BorderLayout(100, 100));
        panel.add(heads,BorderLayout.LINE_START);
        panel.add(tails,BorderLayout.LINE_END);
        panel.add(display,BorderLayout.CENTER); //HERE IS ERROR
        panel.add(comboul,BorderLayout.PAGE_START);
    }


    public void dacaHeads(){
        if(heads.getModel().isPressed()) predictie = 0;
    }
    public void dacaTails(){
        if(tails.getModel().isPressed()) predictie = 1;



        heads.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e){
               dacaHeads();
               obiect.flip();

               if(predictie == obiect.returnStatus() ){
                   String s = comboul.getText();
                   int combo = Integer.valueOf(s);
                   s = Integer.toString(++combo);
                   comboul.setText(s);}
                   else{
                       String z = "0";
                       comboul.setText(z);
                   }
            }
        });
        tails.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e){
                dacaTails();
                obiect.flip();
                if(predictie == obiect.returnStatus() ){
                    String s = comboul.getText();
                    int combo = Integer.valueOf(s);
                    s = Integer.toString(++combo);
                    comboul.setText(s);}
                else{
                        String z = "0";
                comboul.setText(z);
            }
        }
        });



    }}
import java.a



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: