首先,我不是要代码...我刚刚到了不知道如何进步的地步...有人可以向我解释如何开始刽子手的这一步吗?我已经有一系列按钮:
String b[]={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
for(i = 0; i < buttons.length; i++) {
buttons[i] = new JButton(b[i]);
panel.add(buttons[i]);
}
然后我试图隐藏的词来自一个列表:
public String readWord() {
try {
BufferedReader reader = new BufferedReader(new FileReader("Words.txt"));
String line = reader.readLine();
List<String> words = new ArrayList<String>();
while(line != null) {
String[] wordsLine = line.split(" ");
boolean addAll = words.addAll(Arrays.asList(wordsLine));
line = reader.readLine();
}
Random rand = new Random(System.currentTimeMillis());
String randomWord = words.get(rand.nextInt(words.size()));
return randomWord;
} catch (Exception e) {
return null;
}
}
现在有人可以指点我正确的方向来用“-”隐藏这个词。当用户点击正确的按钮时,字母必须出现......
如果它没有像以前那么清楚,我很抱歉。