对象引用未被识别

时间:2015-05-03 07:19:31

标签: java swing

private GameController gc = new GameController();

private boolean timerstart = false;

private JButton bhit = new JButton("HIT");

private JButton bstand = new JButton("STAND");

private JButton bdd = new JButton("DOUBLE DOWN");

// private JButton bsplit = new JButton("SPLIT")

private JButton 5chips = new JButton("5");
private JButton 10chips = new JButton("10");
private JButton 25chips = new JButton("25");
private JButton 100chips = new JButton("100");

private JTextArea tap = new JTextArea(5,5);

private JTextArea tad = new JTextArea(5,5);

private JTextArea tac = new JTextArea("Welcome to BlackJack Simulator!",1,5);

private Container cp = getContentPane();
// create the panel containing panels
private JPanel mainchippanel = new JPanel(new FlowLayout());
// create the panel to contain the buttons
private JPanel chipandta = new JPanel(new BorderLayout());

private JPanel chipbuttons = new JPanel(new FlowLayout());

private JPanel playeroptions = new JPanel(new FlowLayout());

private JPanel optnsandta = new JPanel(new BorderLayout());

private JPanel mainoptnpanel = new JPanel(new FlowLayout());

private JPanel handdisplays = new JPanel(new BorderLayout());

private JPanel main1 = new JPanel(new BorderLayout());

private JPanel main2 = new JPanel(new BorderLayout());

我正在创建一个小程序,由于某种原因,只有从gc到bdd的代码被识别出来,就好像它的所有来自JButton的5chips及以后的代码都不存在。

我知道这是因为类视图没有显示代码超过bdd的引用,并且输出不断为每个对bdd之前的对象的引用提供“预期”错误。

我不知道为什么会这样,所以任何帮助都会受到赞赏。感谢。

1 个答案:

答案 0 :(得分:2)

Java Tutorials

无法以带有数字的变量名开头。 改为:

private JButton chips5 = new JButton("5");
private JButton chips10 = new JButton("10");
private JButton chips25 = new JButton("25");
private JButton chips100 = new JButton("100");