1 /*******************************************************************************
2 * Copyright (c) 2000, 2016 IBM Corporation and others.
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
9 * SPDX-License-Identifier: EPL-2.0
12 * IBM Corporation - initial API and implementation
13 * Lars Vogel <Lars.Vogel@vogella.com> - Bug 506538
14 *******************************************************************************/
15 package org.eclipse.swt.events;
18 import java.util.function.*;
20 import org.eclipse.swt.internal.*;
23 * Classes which implement this interface provide methods
24 * that deal with the events that are generated as controls
25 * gain and lose focus.
27 * After creating an instance of a class that implements
28 * this interface it can be added to a control using the
29 * <code>addFocusListener</code> method and removed using
30 * the <code>removeFocusListener</code> method. When a
31 * control gains or loses focus, the appropriate method
38 public interface FocusListener extends SWTEventListener {
41 * Sent when a control gets focus.
43 * @param e an event containing information about the focus change
45 void focusGained(FocusEvent e);
48 * Sent when a control loses focus.
50 * @param e an event containing information about the focus change
52 void focusLost(FocusEvent e);
56 * Static helper method to create a <code>FocusListener</code> for the
57 * {@link #focusGained(FocusEvent e)}) method with a lambda expression.
59 * @param c the consumer of the event
60 * @return FocusListener
63 static FocusListener focusGainedAdapter(Consumer<FocusEvent> c) {
64 return new FocusAdapter() {
66 public void focusGained(FocusEvent e) {
73 * Static helper method to create a <code>FocusListener</code> for the
74 * {@link #focusLost(FocusEvent e)}) method with a lambda expression.
76 * @param c the consumer of the event
77 * @return FocusListener
80 static FocusListener focusLostAdapter(Consumer<FocusEvent> c) {
81 return new FocusAdapter() {
83 public void focusLost(FocusEvent e) {