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"));
 }
示例#2
0
  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
示例#3
0
  /** 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));
  }
示例#4
0
  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