Geen cache-versie.

Caching uitgeschakeld. Standaardinstelling voor deze pagina:ingeschakeld (code LNG204)
Als het scherm te langzaam is, kunt u de gebruikersmodus uitschakelen om de cacheversie te bekijken.
javax.swing

Class DefaultButtonModel

  • All Implemented Interfaces:
    ItemSelectable, Serializable, ButtonModel
    Direct Known Subclasses:
    JToggleButton.ToggleButtonModel

    public class DefaultButtonModel
    extends Object
    implements ButtonModel, Serializable
    The default implementation of a Button component's data model.

    Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see XMLEncoder.

    • Field Detail

      • stateMask

        protected int stateMask
        The bitmask used to store the state of the button.
      • actionCommand

        protected String actionCommand
        The action command string fired by the button.
      • group

        protected ButtonGroup group
        The button group that the button belongs to.
      • mnemonic

        protected int mnemonic
        The button's mnemonic.
      • changeEvent

        protected transient ChangeEvent changeEvent
        Only one ChangeEvent is needed per button model instance since the event's only state is the source property. The source of events generated is always "this".
      • listenerList

        protected EventListenerList listenerList
        Stores the listeners on this model.
      • ARMED

        public static final int ARMED
        Identifies the "armed" bit in the bitmask, which indicates partial commitment towards choosing/triggering the button.
        See Also:
        Constant Field Values
      • SELECTED

        public static final int SELECTED
        Identifies the "selected" bit in the bitmask, which indicates that the button has been selected. Only needed for certain types of buttons - such as radio button or check box.
        See Also:
        Constant Field Values
      • PRESSED

        public static final int PRESSED
        Identifies the "pressed" bit in the bitmask, which indicates that the button is pressed.
        See Also:
        Constant Field Values
      • ENABLED

        public static final int ENABLED
        Identifies the "enabled" bit in the bitmask, which indicates that the button can be selected by an input device (such as a mouse pointer).
        See Also:
        Constant Field Values
      • ROLLOVER

        public static final int ROLLOVER
        Identifies the "rollover" bit in the bitmask, which indicates that the mouse is over the button.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DefaultButtonModel

        public DefaultButtonModel()
        Constructs a DefaultButtonModel.
    • Method Detail

      • isArmed

        public boolean isArmed()
        Indicates partial commitment towards triggering the button.
        Specified by:
        isArmed in interface ButtonModel
        Returns:
        true if the button is armed, and ready to be triggered
        See Also:
        ButtonModel.setArmed(boolean)
      • isSelected

        public boolean isSelected()
        Indicates if the button has been selected. Only needed for certain types of buttons - such as radio buttons and check boxes.
        Specified by:
        isSelected in interface ButtonModel
        Returns:
        true if the button is selected
      • isEnabled

        public boolean isEnabled()
        Indicates if the button can be selected or triggered by an input device, such as a mouse pointer.
        Specified by:
        isEnabled in interface ButtonModel
        Returns:
        true if the button is enabled
      • isPressed

        public boolean isPressed()
        Indicates if the button is pressed.
        Specified by:
        isPressed in interface ButtonModel
        Returns:
        true if the button is pressed
      • isRollover

        public boolean isRollover()
        Indicates that the mouse is over the button.
        Specified by:
        isRollover in interface ButtonModel
        Returns:
        true if the mouse is over the button
      • setArmed

        public void setArmed(boolean b)
        Marks the button as armed or unarmed.
        Specified by:
        setArmed in interface ButtonModel
        Parameters:
        b - whether or not the button should be armed
      • setEnabled

        public void setEnabled(boolean b)
        Enables or disables the button.
        Specified by:
        setEnabled in interface ButtonModel
        Parameters:
        b - whether or not the button should be enabled
        See Also:
        ButtonModel.isEnabled()
      • setSelected

        public void setSelected(boolean b)
        Selects or deselects the button.
        Specified by:
        setSelected in interface ButtonModel
        Parameters:
        b - true selects the button, false deselects the button
      • setPressed

        public void setPressed(boolean b)
        Sets the button to pressed or unpressed.
        Specified by:
        setPressed in interface ButtonModel
        Parameters:
        b - whether or not the button should be pressed
        See Also:
        ButtonModel.isPressed()
      • setRollover

        public void setRollover(boolean b)
        Sets or clears the button's rollover state
        Specified by:
        setRollover in interface ButtonModel
        Parameters:
        b - whether or not the button is in the rollover state
        See Also:
        ButtonModel.isRollover()
      • setMnemonic

        public void setMnemonic(int key)
        Sets the keyboard mnemonic (shortcut key or accelerator key) for the button.
        Specified by:
        setMnemonic in interface ButtonModel
        Parameters:
        key - an int specifying the accelerator key
      • fireStateChanged

        protected void fireStateChanged()
        Notifies all listeners that have registered interest for notification on this event type. The event instance is created lazily.
        See Also:
        EventListenerList
      • fireActionPerformed

        protected void fireActionPerformed(ActionEvent e)
        Notifies all listeners that have registered interest for notification on this event type.
        Parameters:
        e - the ActionEvent to deliver to listeners
        See Also:
        EventListenerList
      • fireItemStateChanged

        protected void fireItemStateChanged(ItemEvent e)
        Notifies all listeners that have registered interest for notification on this event type.
        Parameters:
        e - the ItemEvent to deliver to listeners
        See Also:
        EventListenerList
      • getListeners

        public <T extends EventListener> T[] getListeners(Class<T> listenerType)
        Returns an array of all the objects currently registered as FooListeners upon this model. FooListeners are registered using the addFooListener method.

        You can specify the listenerType argument with a class literal, such as FooListener.class. For example, you can query a DefaultButtonModel instance m for its action listeners with the following code:

        ActionListener[] als = (ActionListener[])(m.getListeners(ActionListener.class));
        If no such listeners exist, this method returns an empty array.
        Parameters:
        listenerType - the type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener
        Returns:
        an array of all objects registered as FooListeners on this model, or an empty array if no such listeners have been added
        Throws:
        ClassCastException - if listenerType doesn't specify a class or interface that implements java.util.EventListener
        Since:
        1.3
        See Also:
        getActionListeners(), getChangeListeners(), getItemListeners()
      • setGroup

        public void setGroup(ButtonGroup group)
        Identifies the group the button belongs to -- needed for radio buttons, which are mutually exclusive within their group.
        Specified by:
        setGroup in interface ButtonModel
        Parameters:
        group - the ButtonGroup the button belongs to
      • getGroup

        public ButtonGroup getGroup()
        Returns the group that the button belongs to. Normally used with radio buttons, which are mutually exclusive within their group.
        Returns:
        the ButtonGroup that the button belongs to
        Since:
        1.3

Nederlandse vertaling

U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.

Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.

Bij voorbaat dank.

Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-javax/swing/defaultbuttonmodel.html

De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.

Referenties

  1. Bekijk - html-document Taal van het document:fr Manuel PHP : https://docs.oracle.com

Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.

Inhoudsopgave Haut