⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abstractbutton.java

📁 linux下编程用 编译软件
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
   * resulting ChangeListener in its <code>changeListener</code> member   * field, and subscribes it to the button's model. If the button's model   * is changed, this listener is unsubscribed from the old model and   * subscribed to the new one.</p>   *   * @return The new ChangeListener   */  protected ChangeListener createChangeListener()  {    return new ButtonChangeListener();  }  /**   * <p>Factory method which creates a {@link ItemListener}, used to   * subscribe to ItemEvents from the button's model. Subclasses of   * AbstractButton may wish to override the listener used to subscribe to   * such ItemEvents. By default, the listener just propagates the   * {@link ItemEvent} to the button's ItemListeners, via the {@link   * AbstractButton#fireItemStateChanged} method.</p>   *   * <p>The button calls this method during construction, stores the   * resulting ItemListener in its <code>changeListener</code> member   * field, and subscribes it to the button's model. If the button's model   * is changed, this listener is unsubscribed from the old model and   * subscribed to the new one.</p>   *   * <p>Note that ItemEvents are only generated from the button's model   * when the model's <em>selected</em> property changes. If you want to   * subscribe to other properties of the model, you must subscribe to   * ChangeEvents.   *   * @return The new ItemListener   */  protected  ItemListener createItemListener()  {    return new ItemListener()      {        public void itemStateChanged(ItemEvent e)        {          AbstractButton.this.fireItemStateChanged(e);        }      };  }  /**   * Programmatically perform a "click" on the button: arming, pressing,   * waiting, un-pressing, and disarming the model.   */  public void doClick()  {    doClick(100);  }  /**   * Programmatically perform a "click" on the button: arming, pressing,   * waiting, un-pressing, and disarming the model.   *   * @param pressTime The number of milliseconds to wait in the pressed state   */  public void doClick(int pressTime)  {    ButtonModel mod = getModel();    if (mod != null)      {        mod.setArmed(true);        mod.setPressed(true);        try          {            java.lang.Thread.sleep(pressTime);          }        catch (java.lang.InterruptedException e)          {            // probably harmless          }        mod.setPressed(false);        mod.setArmed(false);      }  }  /**   * Return the button's disabled selected icon. The look and feel class   * should paint this icon when the "enabled" property of the button's model   * is <code>false</code> and its "selected" property is   * <code>true</code>. This icon can be <code>null</code>, in which case   * it is synthesized from the button's selected icon.   *   * @return The current disabled selected icon   */  public Icon getDisabledSelectedIcon()  {    return disabledSelectedIcon;  }  /**   * Set the button's disabled selected icon. The look and feel class   * should paint this icon when the "enabled" property of the button's model   * is <code>false</code> and its "selected" property is   * <code>true</code>. This icon can be <code>null</code>, in which case   * it is synthesized from the button's selected icon.   *   * @param icon The new disabled selected icon   */  public void setDisabledSelectedIcon(Icon icon)  {    if (disabledSelectedIcon == icon)      return;        Icon old = disabledSelectedIcon;    disabledSelectedIcon = icon;    firePropertyChange(DISABLED_SELECTED_ICON_CHANGED_PROPERTY, old, icon);    revalidate();    repaint();          }  /**   * Return the button's rollover icon. The look and feel class should   * paint this icon when the "rolloverEnabled" property of the button is   * <code>true</code> and the mouse rolls over the button.   *   * @return The current rollover icon   */  public Icon getRolloverIcon()  {    return rolloverIcon;  }  /**   * Set the button's rollover icon. The look and feel class should   * paint this icon when the "rolloverEnabled" property of the button is   * <code>true</code> and the mouse rolls over the button.   *   * @param r The new rollover icon   */  public void setRolloverIcon(Icon r)  {    if (rolloverIcon == r)      return;        Icon old = rolloverIcon;    rolloverIcon = r;    firePropertyChange(ROLLOVER_ICON_CHANGED_PROPERTY, old, rolloverIcon);    revalidate();    repaint();  }  /**   * Return the button's rollover selected icon. The look and feel class   * should paint this icon when the "rolloverEnabled" property of the button   * is <code>true</code>, the "selected" property of the button's model is   * <code>true</code>, and the mouse rolls over the button.   *   * @return The current rollover selected icon   */  public Icon getRolloverSelectedIcon()  {    return rolloverSelectedIcon;  }  /**   * Set the button's rollover selected icon. The look and feel class   * should paint this icon when the "rolloverEnabled" property of the button   * is <code>true</code>, the "selected" property of the button's model is   * <code>true</code>, and the mouse rolls over the button.   *   * @param r The new rollover selected icon   */  public void setRolloverSelectedIcon(Icon r)  {    if (rolloverSelectedIcon == r)      return;        Icon old = rolloverSelectedIcon;    rolloverSelectedIcon = r;    firePropertyChange(ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, old, r);    revalidate();    repaint();  }  /**   * Return the button's selected icon. The look and feel class should   * paint this icon when the "selected" property of the button's model is   * <code>true</code>, and either the "rolloverEnabled" property of the   * button is <code>false</code> or the mouse is not currently rolled   * over the button.   *   * @return The current selected icon   */  public Icon getSelectedIcon()  {    return selectedIcon;  }  /**   * Set the button's selected icon. The look and feel class should   * paint this icon when the "selected" property of the button's model is   * <code>true</code>, and either the "rolloverEnabled" property of the   * button is <code>false</code> or the mouse is not currently rolled   * over the button.   *   * @param s The new selected icon   */  public void setSelectedIcon(Icon s)  {    if (selectedIcon == s)      return;        Icon old = selectedIcon;    selectedIcon = s;    firePropertyChange(SELECTED_ICON_CHANGED_PROPERTY, old, s);    revalidate();    repaint();  }  /**   * Returns an single-element array containing the "text" property of the   * button if the "selected" property of the button's model is   * <code>true</code>, otherwise returns <code>null</code>.   *   * @return The button's "selected object" array   */  public Object[] getSelectedObjects()  {    if (isSelected())      {        Object[] objs = new Object[1];        objs[0] = getText();        return objs;      }    else      {        return null;      }  }  /**   * Called when image data becomes available for one of the button's icons.   *   * @param img The image being updated   * @param infoflags One of the constant codes in {@link ImageObserver} used   *     to describe updated portions of an image.   * @param x X coordinate of the region being updated   * @param y Y coordinate of the region being updated   * @param w Width of the region beign updated   * @param h Height of the region being updated   *   * @return <code>true</code> if img is equal to the button's current icon,   *     otherwise <code>false</code>   */  public boolean imageUpdate(Image img, int infoflags, int x, int y, int w,                             int h)  {    return current_icon == img;  }  /**   * Returns the value of the button's "contentAreaFilled" property. This   * property indicates whether the area surrounding the text and icon of   * the button should be filled by the look and feel class.  If this   * property is <code>false</code>, the look and feel class should leave   * the content area transparent.   *   * @return The current value of the "contentAreaFilled" property   */  public boolean isContentAreaFilled()  {    return contentAreaFilled;  }  /**   * Sets the value of the button's "contentAreaFilled" property. This   * property indicates whether the area surrounding the text and icon of   * the button should be filled by the look and feel class.  If this   * property is <code>false</code>, the look and feel class should leave   * the content area transparent.   *   * @param b The new value of the "contentAreaFilled" property   */  public void setContentAreaFilled(boolean b)  {    if (contentAreaFilled == b)      return;        boolean old = contentAreaFilled;    contentAreaFilled = b;    firePropertyChange(CONTENT_AREA_FILLED_CHANGED_PROPERTY, old, b);    // The JDK sets the opaque property to the value of the contentAreaFilled    // property, so should we do.    setOpaque(b);   }  /**   * Paints the button's border, if the button's "borderPainted" property is   * <code>true</code>, by out calling to the button's look and feel class.   *   * @param g The graphics context used to paint the border   */  protected void paintBorder(Graphics g)  {    if (isBorderPainted())      super.paintBorder(g);  }  /**   * Returns a string, used only for debugging, which identifies or somehow   * represents this button. The exact value is implementation-defined.   *   * @return A string representation of the button   */  protected String paramString()  {    StringBuffer sb = new StringBuffer();    sb.append(super.paramString());    sb.append(",defaultIcon=");    if (getIcon() != null)      sb.append(getIcon());    sb.append(",disabledIcon=");    if (getDisabledIcon() != null)      sb.append(getDisabledIcon());    sb.append(",disabledSelectedIcon=");    if (getDisabledSelectedIcon() != null)      sb.append(getDisabledSelectedIcon());    sb.append(",margin=");    if (getMargin() != null)      sb.append(getMargin());    sb.append(",paintBorder=").append(isBorderPainted());    sb.append(",paintFocus=").append(isFocusPainted());    sb.append(",pressedIcon=");    if (getPressedIcon() != null)      sb.append(getPressedIcon());    sb.append(",rolloverEnabled=").append(isRolloverEnabled());    sb.append(",rolloverIcon=");    if (getRolloverIcon() != null)      sb.append(getRolloverIcon());    sb.append(",rolloverSelected=");    if (getRolloverSelectedIcon() != null)      sb.append(getRolloverSelectedIcon());    sb.append(",selectedIcon=");    if (getSelectedIcon() != null)      sb.append(getSelectedIcon());    sb.append(",text=");    if (getText() != null)      sb.append(getText());    return sb.toString();  }  /**   * Set the "UI" property of the button, which is a look and feel class   * responsible for handling the button's input events and painting it.   *   * @param ui The new "UI" property   */  public void setUI(ButtonUI ui)  {    super.setUI(ui);  }    /**   * Set the "UI" property of the button, which is a look and feel class   * responsible for handling the button's input events and painting it.   *   * @return The current "UI" property   */  public ButtonUI getUI()  {    return (ButtonUI) ui;  }    /**   * Set the "UI" property to a class constructed, via the {@link   * UIManager}, from the current look and feel. This should be overridden   * for each subclass of AbstractButton, to retrieve a suitable {@link   * ButtonUI} look and feel class.   */  public void updateUI()  {    // TODO: What to do here?  }  /**   * Returns the current time in milliseconds in which clicks gets coalesced   * into a single <code>ActionEvent</code>.   *   * @return the time in milliseconds   *    * @since 1.4   */  public long getMultiClickThreshhold()  {    return multiClickThreshhold;  }  /**   * Sets the time in milliseconds in which clicks gets coalesced into a single   * <code>ActionEvent</code>.   *   * @param threshhold the time in milliseconds   *    * @since 1.4   */  public void setMultiClickThreshhold(long threshhold)  {    if (threshhold < 0)      throw new IllegalArgumentException();    multiClickThreshhold = threshhold;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -