Ejemplo n.º 1
0
  /**
   * Sets the <code>defaultButton</code> property, which determines the current default button for
   * this <code>JRootPane</code>. The default button is the button which will be activated when a
   * UI-defined activation event (typically the <b>Enter</b> key) occurs in the root pane regardless
   * of whether or not the button has keyboard focus (unless there is another component within the
   * root pane which consumes the activation event, such as a <code>JTextPane</code>). For default
   * activation to work, the button must be an enabled descendent of the root pane when activation
   * occurs. To remove a default button from this root pane, set this property to <code>null</code>.
   *
   * @see JButton#isDefaultButton
   * @param defaultButton the <code>JButton</code> which is to be the default button
   * @beaninfo description: The button activated by default in this root pane
   */
  public void setDefaultButton(JButton defaultButton) {
    JButton oldDefault = this.defaultButton;

    if (oldDefault != defaultButton) {
      this.defaultButton = defaultButton;

      if (oldDefault != null) {
        oldDefault.repaint();
      }
      if (defaultButton != null) {
        defaultButton.repaint();
      }
    }

    firePropertyChange("defaultButton", oldDefault, defaultButton);
  }