public class DefaultButtonModel extends Object implements ButtonModel, Serializable
Button组件的数据模型的默认实现。 
        警告:此类的序列化对象与将来的Swing版本不兼容。 当前的序列化支持适用于运行相同版本的Swing的应用程序之间的短期存储或RMI。 从1.4版本开始,对所有JavaBeans的长期存储的支持已经添加到java.beans包中。 请参阅XMLEncoder 。 
| Modifier and Type | Field and Description | 
|---|---|
| protected String | actionCommand
              按钮触发的动作命令字符串。 
             | 
| static int | ARMED
              标识位掩码中的“布防”位,这表示部分承诺选择/触发按钮。 
             | 
| protected ChangeEvent | changeEvent
              每个按钮模型实例只需要一个 
              ChangeEvent,因为事件的唯一状态是源属性。 | 
| static int | ENABLED
              标识位掩码中的“已启用”位,表示该按钮可由输入设备(如鼠标指针)选择。 
             | 
| protected ButtonGroup | group
              按钮所属的按钮组。 
             | 
| protected EventListenerList | listenerList
              在这个模型上存储听众。 
             | 
| protected int | mnemonic
              按钮的助记符 
             | 
| static int | PRESSED
              标识位掩码中的“已按”位,表示该按钮被按下。 
             | 
| static int | ROLLOVER
              标识位掩码中的“翻转”位,表示鼠标在按钮上方。 
             | 
| static int | SELECTED
              标识位掩码中的“选定”位,表示该按钮已被选中。 
             | 
| protected int | stateMask
              该位掩码用于存储按钮的状态。 
             | 
| Constructor and Description | 
|---|
| DefaultButtonModel()
              构造一个 
              DefaultButtonModel。 | 
| Modifier and Type | Method and Description | 
|---|---|
| void | addActionListener(ActionListener l)
              添加一个 
              ActionListener模型。 | 
| void | addChangeListener(ChangeListener l)
              在模型中添加一个 
              ChangeListener。 | 
| void | addItemListener(ItemListener l)
              添加一个 
              ItemListener模型。 | 
| protected void | fireActionPerformed(ActionEvent e)
              通知所有在此事件类型上通知有兴趣的听众。 
             | 
| protected void | fireItemStateChanged(ItemEvent e)
              通知所有在此事件类型上通知有兴趣的听众。 
             | 
| protected void | fireStateChanged()
              通知所有在此事件类型上通知有兴趣的听众。 
             | 
| String | getActionCommand()
              返回按钮的动作命令字符串。 
             | 
| ActionListener[] | getActionListeners()
              返回在此 
              DefaultButtonModel上DefaultButtonModel的所有动作侦听器的DefaultButtonModel。 | 
| ChangeListener[] | getChangeListeners()
              返回在此 
              DefaultButtonModel上DefaultButtonModel的所有更改监听器的DefaultButtonModel。 | 
| ButtonGroup | getGroup()
              返回按钮所属的组。 
             | 
| ItemListener[] | getItemListeners()
              返回在此 
              DefaultButtonModel上DefaultButtonModel的所有项目侦听器的DefaultButtonModel。 | 
| <T extends EventListener> | getListeners(类<T> listenerType)
              返回此模型上当前注册为 
              FooListener的所有对象的数组。 | 
| int | getMnemonic()
              获取按钮的键盘助记符。 
             | 
| Object[] | getSelectedObjects()
              被覆盖返回 
              null。 | 
| boolean | isArmed()
              表示部分承诺触发按钮。 
             | 
| boolean | isEnabled()
              指示按钮是否可以由输入设备(如鼠标指针)选择或触发。 
             | 
| boolean | isPressed()
              指示按下按钮。 
             | 
| boolean | isRollover()
              表示鼠标在按钮上方。 
             | 
| boolean | isSelected()
              指示按钮是否已被选中。 
             | 
| void | removeActionListener(ActionListener l)
              从模型中移除 
              ActionListener。 | 
| void | removeChangeListener(ChangeListener l)
              从模型中移除 
              ChangeListener。 | 
| void | removeItemListener(ItemListener l)
              从模型中删除 
              ItemListener。 | 
| void | setActionCommand(String actionCommand)
              设置当 
              ActionEvent按钮时作为ActionEvent一部分发送的动作命令字符串。 | 
| void | setArmed(boolean b)
              将按钮标记为武装或非武装。 
             | 
| void | setEnabled(boolean b)
              启用或禁用按钮。 
             | 
| void | setGroup(ButtonGroup group)
              标识按钮所属的组 - 单选按钮所需的组,它们在组内是相互排斥的。 
             | 
| void | setMnemonic(int key)
              设置按钮的键盘助记符(快捷键或加速键)。 
             | 
| void | setPressed(boolean b)
              将按钮设置为按下或未按下。 
             | 
| void | setRollover(boolean b)
              设置或清除按钮的翻转状态 
             | 
| void | setSelected(boolean b)
              选择或取消选择按钮。 
             | 
protected int stateMask
protected String actionCommand
protected ButtonGroup group
protected int mnemonic
protected transient ChangeEvent changeEvent
ChangeEvent ,因为事件的唯一状态是源属性。 
           生成的事件的来源总是“这”。 
          protected EventListenerList listenerList
public static final int ARMED
public static final int SELECTED
public static final int PRESSED
public static final int ENABLED
public static final int ROLLOVER
public void setActionCommand(String actionCommand)
ActionEvent按钮时作为 
           ActionEvent一部分发送的动作命令字符串。 
          setActionCommand在接口 
            ButtonModel 
           actionCommand - 
            String生成的事件的String 
           ButtonModel.getActionCommand() , 
            ActionEvent.getActionCommand() 
           public String getActionCommand()
getActionCommand在接口 
            ButtonModel 
           String生成的事件的String 
           ButtonModel.setActionCommand(java.lang.String) 
           public boolean isArmed()
isArmed在接口 
            ButtonModel 
           true如果按钮被布防,并准备被触发 
           ButtonModel.setArmed(boolean) 
           public boolean isSelected()
isSelected在接口 
            ButtonModel 
           true如果选择按钮 
           public boolean isEnabled()
isEnabled在接口 
            ButtonModel 
           true如果按钮被启用 
           public boolean isPressed()
isPressed在界面 
            ButtonModel 
           true如果按下按钮 
           public boolean isRollover()
isRollover在接口 
            ButtonModel 
           true如果鼠标在按钮上方 
           public void setArmed(boolean b)
setArmed在接口 
            ButtonModel 
           b - 是否应该按下按钮 
           public void setEnabled(boolean b)
setEnabled在界面 
            ButtonModel 
           b - 是否应启用按钮 
           ButtonModel.isEnabled() 
           public void setSelected(boolean b)
setSelected在接口 
            ButtonModel 
           b - 
            true选择按钮, 
            false取消选择按钮 
           public void setPressed(boolean b)
setPressed在接口 
            ButtonModel 
           b - 是否应按下按钮 
           ButtonModel.isPressed() 
           public void setRollover(boolean b)
setRollover在接口 
            ButtonModel 
           b - 按钮是否处于翻转状态 
           ButtonModel.isRollover() 
           public void setMnemonic(int key)
setMnemonic在接口 
            ButtonModel 
           key - 一个指定加速键的int 
           public int getMnemonic()
getMnemonic中的 
            ButtonModel 
           ButtonModel.setMnemonic(int) 
           public void addChangeListener(ChangeListener l)
ChangeListener 。 
          addChangeListener中的 
            ButtonModel 
           l - 收听者添加 
           public void removeChangeListener(ChangeListener l)
ChangeListener 。 
          removeChangeListener在界面 
            ButtonModel 
           l - 要删除的侦听器 
           public ChangeListener[] getChangeListeners()
DefaultButtonModel上 
           DefaultButtonModel的所有更改侦听器的 
           DefaultButtonModel 。 
          ChangeListener s或一个空数组,如果没有更改监听器当前注册 
           addChangeListener(javax.swing.event.ChangeListener) , 
            removeChangeListener(javax.swing.event.ChangeListener) 
           protected void fireStateChanged()
EventListenerList 
           public void addActionListener(ActionListener l)
ActionListener 。 
          addActionListener在界面 
            ButtonModel 
           l - 要添加的监听器 
           public void removeActionListener(ActionListener l)
ActionListener 。 
          removeActionListener在界面 
            ButtonModel 
           l - 要删除的侦听器 
           public ActionListener[] getActionListeners()
DefaultButtonModel上 
           DefaultButtonModel的所有动作侦听器的 
           DefaultButtonModel 。 
          ActionListener s或一个空数组,如果没有动作侦听器当前注册 
           addActionListener(java.awt.event.ActionListener) , 
            removeActionListener(java.awt.event.ActionListener) 
           protected void fireActionPerformed(ActionEvent e)
e -在 
            ActionEvent交付给听众 
           EventListenerList 
           public void addItemListener(ItemListener l)
ItemListener 。 
          addItemListener在界面 
            ItemSelectable 
           addItemListener在界面 
            ButtonModel 
           l - 要添加的收听者 
           ItemEvent 
           public void removeItemListener(ItemListener l)
ItemListener 。 
          removeItemListener在界面 
            ItemSelectable 
           removeItemListener在界面 
            ButtonModel 
           l - 要删除的侦听器 
           ItemEvent 
           public ItemListener[] getItemListeners()
DefaultButtonModel上 
           DefaultButtonModel的所有项目侦听器的 
           DefaultButtonModel 。 
          ItemListener s或一个空数组,如果没有项目监听器当前注册 
           addItemListener(java.awt.event.ItemListener) , 
            removeItemListener(java.awt.event.ItemListener) 
           protected void fireItemStateChanged(ItemEvent e)
e -在 
            ItemEvent交付给听众 
           EventListenerList 
           public <T extends EventListener> T[] getListeners(类<T> listenerType)
FooListener的所有对象的数组。 
           FooListener使用addFooListener 。 
            您可以使用类文字指定listenerType参数,例如FooListener.class 。 例如,您可以使用以下代码查询DefaultButtonModel实例m的操作侦听器: 
  ActionListener[] als = (ActionListener[])(m.getListeners(ActionListener.class));  
           如果没有这样的侦听器存在,这个方法返回一个空数组。 
          listenerType - 所请求的听众的类型; 
            此参数应指定从java.util.EventListener下降的java.util.EventListener 
           FooListener的所有对象的数组,如果没有添加这样的侦听器,则为空数组 
           ClassCastException - 如果 
            listenerType没有指定实现java.util.EventListener的类或 
            java.util.EventListener 
           getActionListeners() , 
            getChangeListeners() , 
            getItemListeners() 
           public Object[] getSelectedObjects()
null 。 
          getSelectedObjects在接口 
            ItemSelectable 
           public void setGroup(ButtonGroup group)
setGroup在界面 
            ButtonModel 
           group - 该按钮属于 
            ButtonGroup 
           public ButtonGroup getGroup()
ButtonGroup 
            Submit a bug or feature 
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
 Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.