FocusEvent (Java SE 10 & JDK 10 )

    • Field Detail

      • FOCUS_FIRST

        public static final int FOCUS_FIRST

        The first number in the range of ids used for focus events.

        See Also:
        Constant Field Values
      • FOCUS_LAST

        public static final int FOCUS_LAST

        The last number in the range of ids used for focus events.

        See Also:
        Constant Field Values
      • FOCUS_GAINED

        public static final int FOCUS_GAINED

        This event indicates that the Component is now the focus owner.

        See Also:
        Constant Field Values
      • FOCUS_LOST

        public static final int FOCUS_LOST

        This event indicates that the Component is no longer the focus owner.

        See Also:
        Constant Field Values
    • Constructor Detail

      • FocusEvent

        public FocusEvent​(Component source,
                          int id,
                          boolean temporary,
                          Component opposite)

        Constructs a FocusEvent object with the specified temporary state, opposite Component and the Cause.UNKNOWN cause. The opposite Component is the other Component involved in this focus change. For a FOCUS_GAINED event, this is the Component that lost focus. For a FOCUS_LOST event, this is the Component that gained focus. If this focus change occurs with a native application, with a Java application in a different VM, or with no other Component, then the opposite Component is null.

        This method throws an IllegalArgumentException if source is null.

        Parameters:
        source - The Component that originated the event
        id - An integer indicating the type of event. For information on allowable values, see the class description for FocusEvent
        temporary - Equals true if the focus change is temporary; false otherwise
        opposite - The other Component involved in the focus change, or null
        Throws:
        IllegalArgumentException - if source equals null
        Since:
        1.4
        See Also:
        EventObject.getSource(), AWTEvent.getID(), isTemporary(), getOppositeComponent(), FocusEvent.Cause.UNKNOWN
      • FocusEvent

        public FocusEvent​(Component source,
                          int id,
                          boolean temporary,
                          Component opposite,
                          FocusEvent.Cause cause)

        Constructs a FocusEvent object with the specified temporary state, opposite Component and the cause. The opposite Component is the other Component involved in this focus change. For a FOCUS_GAINED event, this is the Component that lost focus. For a FOCUS_LOST event, this is the Component that gained focus. If this focus change occurs with a native application, with a Java application in a different VM, or with no other Component, then the opposite Component is null.

        This method throws an IllegalArgumentException if source or cause is null.

        Parameters:
        source - The Component that originated the event
        id - An integer indicating the type of event. For information on allowable values, see the class description for FocusEvent
        temporary - Equals true if the focus change is temporary; false otherwise
        opposite - The other Component involved in the focus change, or null
        cause - The focus event cause.
        Throws:
        IllegalArgumentException - if source equals null or if cause equals null
        Since:
        9
        See Also:
        EventObject.getSource(), AWTEvent.getID(), isTemporary(), getOppositeComponent(), FocusEvent.Cause
      • FocusEvent

        public FocusEvent​(Component source,
                          int id,
                          boolean temporary)

        Constructs a FocusEvent object and identifies whether or not the change is temporary.

        This method throws an IllegalArgumentException if source is null.

        Parameters:
        source - The Component that originated the event
        id - An integer indicating the type of event. For information on allowable values, see the class description for FocusEvent
        temporary - Equals true if the focus change is temporary; false otherwise
        Throws:
        IllegalArgumentException - if source equals null
        See Also:
        EventObject.getSource(), AWTEvent.getID(), isTemporary()
      • FocusEvent

        public FocusEvent​(Component source,
                          int id)

        Constructs a FocusEvent object and identifies it as a permanent change in focus.

        This method throws an IllegalArgumentException if source is null.

        Parameters:
        source - The Component that originated the event
        id - An integer indicating the type of event. For information on allowable values, see the class description for FocusEvent
        Throws:
        IllegalArgumentException - if source equals null
        See Also:
        EventObject.getSource(), AWTEvent.getID()
    • Method Detail

      • isTemporary

        public boolean isTemporary()

        Identifies the focus change event as temporary or permanent.

        Returns:
        true if the focus change is temporary; false otherwise
      • getOppositeComponent

        public Component getOppositeComponent()

        Returns the other Component involved in this focus change. For a FOCUS_GAINED event, this is the Component that lost focus. For a FOCUS_LOST event, this is the Component that gained focus. If this focus change occurs with a native application, with a Java application in a different VM or context, or with no other Component, then null is returned.

        Returns:
        the other Component involved in the focus change, or null
        Since:
        1.4
      • paramString

        public String paramString()

        Returns a parameter string identifying this event. This method is useful for event-logging and for debugging.

        Overrides:
        paramString in class ComponentEvent
        Returns:
        a string identifying the event and its attributes