public AnagramTopComponent() { wordLibrary = WordLibrary.getDefault(); initComponents(); scrambledWord.setText(wordLibrary.getScrambledWord(wordIdx)); setName(NbBundle.getMessage(AnagramTopComponent.class, "CTL_AnagramTopComponent")); setToolTipText(NbBundle.getMessage(AnagramTopComponent.class, "HINT_AnagramTopComponent")); }
private void nextTrialActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_nextTrialActionPerformed wordIdx = (wordIdx + 1) % wordLibrary.getSize(); feedbackLabel.setText(" "); scrambledWord.setText(wordLibrary.getScrambledWord(wordIdx)); guessedWord.setText(""); getRootPane().setDefaultButton(guessButton); guessedWord.requestFocusInWindow(); } // GEN-LAST:event_nextTrialActionPerformed
/** Creates new form Anagrams */ public Anagrams() { wordLibrary = WordLibrary.getDefault(); initComponents(); getRootPane().setDefaultButton(guessButton); scrambledWord.setText(wordLibrary.getScrambledWord(wordIdx)); pack(); guessedWord.requestFocusInWindow(); // Center in the screen Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = getSize(); setLocation( new Point( (screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.width) / 2)); }
private void guessedWordActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_guessedWordActionPerformed if (wordLibrary.isCorrect(wordIdx, guessedWord.getText())) { feedbackLabel.setText("Correct! Try a new word!"); getRootPane().setDefaultButton(nextTrial); } else { feedbackLabel.setText("Incorrect! Try again!"); guessedWord.setText(""); } guessedWord.requestFocusInWindow(); } // GEN-LAST:event_guessedWordActionPerformed