1 /*******************************************************************************
2 * Copyright (c) 2000, 2011 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 *******************************************************************************/
14 package org.eclipse.swt.events;
17 import java.util.function.*;
19 import org.eclipse.swt.internal.*;
22 * Classes which implement this interface provide methods
23 * that deal with the events that are generated by moving
24 * and resizing controls.
26 * After creating an instance of a class that implements
27 * this interface it can be added to a control using the
28 * <code>addControlListener</code> method and removed using
29 * the <code>removeControlListener</code> method. When a
30 * control is moved or resized, the appropriate method will
37 public interface ControlListener extends SWTEventListener {
40 * Sent when the location (x, y) of a control changes relative
41 * to its parent (or relative to the display, for <code>Shell</code>s).
43 * @param e an event containing information about the move
45 void controlMoved(ControlEvent e);
48 * Sent when the size (width, height) of a control changes.
50 * @param e an event containing information about the resize
52 void controlResized(ControlEvent e);
55 * Static helper method to create a <code>ControlListener</code> for the
56 * {@link #controlMoved(ControlEvent e)}) method, given a lambda expression or a method reference.
58 * @param c the consumer of the event
59 * @return ControlListener
62 static ControlListener controlMovedAdapter(Consumer<ControlEvent> c) {
63 return new ControlAdapter() {
65 public void controlMoved(ControlEvent e) {
72 * Static helper method to create a <code>ControlListener</code> for the
73 * {@link #controlResized(ControlEvent e)}) method, given a lambda expression or a method reference.
75 * @param c the consumer of the event
76 * @return ControlListener
79 static ControlListener controlResizedAdapter(Consumer<ControlEvent> c) {
80 return new ControlAdapter() {
82 public void controlResized(ControlEvent e) {