java - 在 scopeJava(16777238) 中无法访问 XXXX 类型的封闭实例
问题描述
如果有人能帮助我理解为什么我的代码不起作用,我将不胜感激!我对Java比较陌生,所以请期待一些noobish错误。另外,如果有必要帮助我解决这个问题,我也可以在这里发布我的代码的其他文件。谢谢你。
包装型号;
import java.awt.event.ActionListener; import javax.swing.JButton; import java.awt.event.ActionEvent; import Controller.WordGuess; import Controller.Dictionary; class Observer implements ActionListener { public void actionPerformed(ActionEvent paramActionEvent) { JButton jButton = (JButton)paramActionEvent.getSource(); if(jButton == WordGuess.this.newGameButton) { for(JButton jButton1 : WordGuess.this.keys) { jButton1.setEnabled(true); } String str1 = Dictonary.getWord(); WordGuess.this.gameKey.setText(str1); String str2 = ""; for(int b = 0; b < str1.length(); b++) { str2 = str2 + "."; } WordGuess.this.progressStatus.setText(str2); WordGuess.this.lifeCount = 5; WordGuess.this.status = 0; WordGuess.this.gameOver = false; } else { jButton.setEnabled(false); char c = jButton.getText().charAt(0); char[] arrayofChar = WordGuess.this.progressStatus.getText().toCharArray(); String str = WordGuess.this.gameKey.getText(); boolean bool = false; for(int b = 0; b < str.length(); b++) { if (c == str.charAt(b)) { arrayofChar[b] = c; bool = true; } } if (bool) { WordGuess.this.progressStatus.setText(new String(arrayofChar)); if(!WordGuess.this.progressStatus.getText().contains(".")) { WordGuess.this.status = 1; WordGuess.this.gameOver = true; } } else { WordGuess.this.lifeCount--; if(WordGuess.this.lifeCount == 0) { WordGuess.this.status = 2; WordGuess.this.gameOver = true; } } } WordGuess.this.repaint(); } }
解决方案
推荐阅读
- ms-access - 使用 Microsoft Access 获取语法错误
- angular - 错误类型错误:无法读取未定义角度的属性“选项卡”
- javascript - “必须使用解构状态分配”:如何从对象解构并放置在对象文字内的属性上
- c++ - 如何将 RC522 UID 十六进制字节转换为十进制?
- regex - Notepad++ 正则表达式去除器在此文本之后的任何内容
- javascript - 我可以为按钮后面的画布设置动画并绘制像素吗?
- twitter - 我怎样才能获得某一天最受欢迎的推文?
- laravel - 在两个不同的 Gitlab CI 中连接到同一个数据库
- java - micronaut - java.lang.IllegalAccessError graalvm 本机编译外部依赖
- java - 如何计算给定 String[][] 和 String[][] 预期返回的平均成绩