Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2017-03-29 05:26:27 -0400
committerLars Vogel2017-03-29 06:15:09 -0400
commitd3e571387cb6d64bb88c657c416877844f9e40a1 (patch)
tree46b0da403877a5e1a2aaf37d9ddc17c3775a45db /examples
parent76fcf9cf9c7ce2aa5aafb1fbb6e678b9c5bb7dff (diff)
downloadeclipse.platform.swt-d3e571387cb6d64bb88c657c416877844f9e40a1.tar.gz
eclipse.platform.swt-d3e571387cb6d64bb88c657c416877844f9e40a1.tar.xz
eclipse.platform.swt-d3e571387cb6d64bb88c657c416877844f9e40a1.zip
Bug 509086 - Use lambda helper methods in org.eclipse.swt.examples -
Part 2 Removes unused imports also Change-Id: I9da1dfac524c54842fc7e1273e355311408328e7 Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/MenuTab.java24
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/RangeTab.java24
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SashTab.java36
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ScaleTab.java17
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ShellTab.java31
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SliderTab.java24
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SpinnerTab.java23
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/javaviewer/JavaViewer.java18
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/paint/PaintExample.java33
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/paint/PaintSurface.java18
10 files changed, 65 insertions, 183 deletions
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/MenuTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/MenuTab.java
index 897d1cce6c..f1fe8aa147 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/MenuTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/MenuTab.java
@@ -11,8 +11,9 @@
package org.eclipse.swt.examples.controlexample;
+import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;
+
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -214,24 +215,9 @@ class MenuTab extends Tab {
closeAllButton.setText (ControlExample.getResourceString("Close_All_Shells"));
/* Add the listeners */
- createButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- createButtonSelected(e);
- }
- });
- closeAllButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- closeAllShells ();
- }
- });
- subMenuButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- subSubMenuButton.setEnabled (subMenuButton.getSelection ());
- }
- });
+ createButton.addSelectionListener(widgetSelectedAdapter(e -> createButtonSelected(e)));
+ closeAllButton.addSelectionListener(widgetSelectedAdapter(e -> closeAllShells ()));
+ subMenuButton.addSelectionListener(widgetSelectedAdapter(e -> subSubMenuButton.setEnabled (subMenuButton.getSelection ())));
/* Set the default state */
barButton.setSelection (true);
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/RangeTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/RangeTab.java
index 74b73f4edf..c101f29c0d 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/RangeTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/RangeTab.java
@@ -11,10 +11,11 @@
package org.eclipse.swt.examples.controlexample;
+import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;
+
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
-import org.eclipse.swt.events.*;
abstract class RangeTab extends Tab {
/* Style widgets added to the "Style" group */
@@ -63,12 +64,7 @@ abstract class RangeTab extends Tab {
maximumSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false));
/* Add the listeners */
- maximumSpinner.addSelectionListener(new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- setWidgetMaximum ();
- }
- });
+ maximumSpinner.addSelectionListener(widgetSelectedAdapter(event -> setWidgetMaximum ()));
}
/**
@@ -92,12 +88,7 @@ abstract class RangeTab extends Tab {
minimumSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false));
/* Add the listeners */
- minimumSpinner.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- setWidgetMinimum ();
- }
- });
+ minimumSpinner.addSelectionListener (widgetSelectedAdapter(event -> setWidgetMinimum ()));
}
@@ -123,12 +114,7 @@ abstract class RangeTab extends Tab {
selectionSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false));
/* Add the listeners */
- selectionSpinner.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- setWidgetSelection ();
- }
- });
+ selectionSpinner.addSelectionListener(widgetSelectedAdapter(event -> setWidgetSelection ()));
}
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SashTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SashTab.java
index 1dc6692ee0..1ddaf306d6 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SashTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SashTab.java
@@ -11,6 +11,8 @@
package org.eclipse.swt.examples.controlexample;
+import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;
+
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
@@ -99,28 +101,22 @@ class SashTab extends Tab {
hSash = new Sash (sashComp, SWT.HORIZONTAL | style);
/* Add the listeners */
- hSash.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- Rectangle rect = vSash.getParent().getClientArea();
- event.y = Math.min (Math.max (event.y, SASH_LIMIT), rect.height - SASH_LIMIT);
- if (event.detail != SWT.DRAG) {
- hSash.setBounds (event.x, event.y, event.width, event.height);
- layout ();
- }
+ hSash.addSelectionListener (widgetSelectedAdapter(event -> {
+ Rectangle rect = vSash.getParent().getClientArea();
+ event.y = Math.min (Math.max (event.y, SASH_LIMIT), rect.height - SASH_LIMIT);
+ if (event.detail != SWT.DRAG) {
+ hSash.setBounds (event.x, event.y, event.width, event.height);
+ layout ();
}
- });
- vSash.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- Rectangle rect = vSash.getParent().getClientArea();
- event.x = Math.min (Math.max (event.x, SASH_LIMIT), rect.width - SASH_LIMIT);
- if (event.detail != SWT.DRAG) {
- vSash.setBounds (event.x, event.y, event.width, event.height);
- layout ();
- }
+ }));
+ vSash.addSelectionListener (widgetSelectedAdapter(event -> {
+ Rectangle rect = vSash.getParent().getClientArea();
+ event.x = Math.min (Math.max (event.x, SASH_LIMIT), rect.width - SASH_LIMIT);
+ if (event.detail != SWT.DRAG) {
+ vSash.setBounds (event.x, event.y, event.width, event.height);
+ layout ();
}
- });
+ }));
sashComp.addControlListener (new ControlAdapter () {
@Override
public void controlResized (ControlEvent event) {
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ScaleTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ScaleTab.java
index 9198892f0b..7bf0d2c199 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ScaleTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ScaleTab.java
@@ -11,10 +11,11 @@
package org.eclipse.swt.examples.controlexample;
+import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;
+
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
-import org.eclipse.swt.events.*;
class ScaleTab extends RangeTab {
/* Example widgets and groups that contain them */
@@ -93,12 +94,7 @@ class ScaleTab extends RangeTab {
incrementSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false));
/* Add the listeners */
- incrementSpinner.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent e) {
- setWidgetIncrement ();
- }
- });
+ incrementSpinner.addSelectionListener (widgetSelectedAdapter(e -> setWidgetIncrement ()));
}
/**
@@ -122,12 +118,7 @@ class ScaleTab extends RangeTab {
pageIncrementSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false));
/* Add the listeners */
- pageIncrementSpinner.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- setWidgetPageIncrement ();
- }
- });
+ pageIncrementSpinner.addSelectionListener (widgetSelectedAdapter(event -> setWidgetPageIncrement ()));
}
/**
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ShellTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ShellTab.java
index cb85a14288..df4e27df6b 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ShellTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ShellTab.java
@@ -11,8 +11,9 @@
package org.eclipse.swt.examples.controlexample;
+import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;
+
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
@@ -102,12 +103,7 @@ class ShellTab extends Tab {
final Button button = new Button(currentShell, SWT.CHECK);
button.setBounds(20, 20, 120, 30);
button.setText(ControlExample.getResourceString("FullScreen"));
- button.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- currentShell.setFullScreen(button.getSelection());
- }
- });
+ button.addSelectionListener(widgetSelectedAdapter(e -> currentShell.setFullScreen(button.getSelection())));
Button close = new Button(currentShell, SWT.PUSH);
close.setBounds(160, 20, 120, 30);
close.setText(ControlExample.getResourceString("Close"));
@@ -235,24 +231,9 @@ class ShellTab extends Tab {
closeAllButton.setLayoutData (gridData);
/* Add the listeners */
- createButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- createButtonSelected(e);
- }
- });
- closeAllButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- closeAllShells ();
- }
- });
- SelectionListener decorationButtonListener = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- decorationButtonSelected(event);
- }
- };
+ createButton.addSelectionListener(widgetSelectedAdapter(e -> createButtonSelected(e)));
+ closeAllButton.addSelectionListener(widgetSelectedAdapter(e -> closeAllShells ()));
+ SelectionListener decorationButtonListener = widgetSelectedAdapter(event -> decorationButtonSelected(event));
noTrimButton.addSelectionListener (decorationButtonListener);
noMoveButton.addSelectionListener(decorationButtonListener);
closeButton.addSelectionListener (decorationButtonListener);
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SliderTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SliderTab.java
index 3ffb0322b6..7fb664defd 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SliderTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SliderTab.java
@@ -11,10 +11,11 @@
package org.eclipse.swt.examples.controlexample;
+import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;
+
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
-import org.eclipse.swt.events.*;
class SliderTab extends RangeTab {
/* Example widgets and groups that contain them */
@@ -93,12 +94,7 @@ class SliderTab extends RangeTab {
incrementSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false));
/* Add the listeners */
- incrementSpinner.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent e) {
- setWidgetIncrement ();
- }
- });
+ incrementSpinner.addSelectionListener (widgetSelectedAdapter(e -> setWidgetIncrement ()));
}
/**
@@ -122,12 +118,7 @@ class SliderTab extends RangeTab {
pageIncrementSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false));
/* Add the listeners */
- pageIncrementSpinner.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- setWidgetPageIncrement ();
- }
- });
+ pageIncrementSpinner.addSelectionListener (widgetSelectedAdapter(event -> setWidgetPageIncrement ()));
}
/**
@@ -151,12 +142,7 @@ class SliderTab extends RangeTab {
thumbSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false));
/* Add the listeners */
- thumbSpinner.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- setWidgetThumb ();
- }
- });
+ thumbSpinner.addSelectionListener (widgetSelectedAdapter(event -> setWidgetThumb ()));
}
/**
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SpinnerTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SpinnerTab.java
index 9af6053eae..3d457bb36f 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SpinnerTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SpinnerTab.java
@@ -11,6 +11,8 @@
package org.eclipse.swt.examples.controlexample;
+import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;
+
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.events.*;
@@ -97,12 +99,7 @@ class SpinnerTab extends RangeTab {
incrementSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false));
/* Add the listeners */
- incrementSpinner.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent e) {
- setWidgetIncrement ();
- }
- });
+ incrementSpinner.addSelectionListener (widgetSelectedAdapter(e -> setWidgetIncrement ()));
}
/**
@@ -126,12 +123,7 @@ class SpinnerTab extends RangeTab {
pageIncrementSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false));
/* Add the listeners */
- pageIncrementSpinner.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- setWidgetPageIncrement ();
- }
- });
+ pageIncrementSpinner.addSelectionListener (widgetSelectedAdapter(event -> setWidgetPageIncrement ()));
}
/**
@@ -155,12 +147,7 @@ class SpinnerTab extends RangeTab {
digitsSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false));
/* Add the listeners */
- digitsSpinner.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent e) {
- setWidgetDigits ();
- }
- });
+ digitsSpinner.addSelectionListener (widgetSelectedAdapter(e -> setWidgetDigits ()));
}
/**
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/javaviewer/JavaViewer.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/javaviewer/JavaViewer.java
index 0af83e0b46..e43e5d0f44 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/javaviewer/JavaViewer.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/javaviewer/JavaViewer.java
@@ -11,6 +11,8 @@
package org.eclipse.swt.examples.javaviewer;
+import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@@ -23,8 +25,6 @@ import java.util.ResourceBundle;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.graphics.Color;
@@ -55,22 +55,12 @@ Menu createFileMenu() {
item = new MenuItem (menu, SWT.PUSH);
item.setText (resources.getString("Open_menuitem"));
item.setAccelerator(SWT.MOD1 + 'O');
- item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- openFile();
- }
- });
+ item.addSelectionListener(widgetSelectedAdapter(event -> openFile()));
// Exit
item = new MenuItem (menu, SWT.PUSH);
item.setText (resources.getString("Exit_menuitem"));
- item.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent e) {
- menuFileExit ();
- }
- });
+ item.addSelectionListener (widgetSelectedAdapter(e -> menuFileExit ()));
return menu;
}
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/paint/PaintExample.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/paint/PaintExample.java
index 1ee6b41b4b..595af4bddf 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/paint/PaintExample.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/paint/PaintExample.java
@@ -11,6 +11,8 @@
package org.eclipse.swt.examples.paint;
+import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;
+
import java.io.IOException;
import java.io.InputStream;
import java.text.MessageFormat;
@@ -20,8 +22,6 @@ import java.util.ResourceBundle;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.accessibility.AccessibleAdapter;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
@@ -163,12 +163,7 @@ public class PaintExample {
item.setText (getResourceString(id + ".label"));
item.setToolTipText(getResourceString(id + ".tooltip"));
item.setImage(tool.image);
- item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- tool.action.run();
- }
- });
+ item.addSelectionListener(widgetSelectedAdapter(e -> tool.action.run()));
final int childID = toolbar.indexOf(item);
toolbar.getAccessible().addAccessibleListener(new AccessibleAdapter() {
@Override
@@ -322,13 +317,10 @@ public class PaintExample {
airbrushRadiusScale.setMaximum(50);
airbrushRadiusScale.setSelection(toolSettings.airbrushRadius);
airbrushRadiusScale.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
- airbrushRadiusScale.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- toolSettings.airbrushRadius = airbrushRadiusScale.getSelection();
- updateToolSettings();
- }
- });
+ airbrushRadiusScale.addSelectionListener(widgetSelectedAdapter(e -> {
+ toolSettings.airbrushRadius = airbrushRadiusScale.getSelection();
+ updateToolSettings();
+ }));
label = new Label(toolSettingsFrame, SWT.NONE);
label.setText(getResourceString("settings.AirbrushIntensity.text"));
@@ -338,13 +330,10 @@ public class PaintExample {
airbrushIntensityScale.setMaximum(100);
airbrushIntensityScale.setSelection(toolSettings.airbrushIntensity);
airbrushIntensityScale.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
- airbrushIntensityScale.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- toolSettings.airbrushIntensity = airbrushIntensityScale.getSelection();
- updateToolSettings();
- }
- });
+ airbrushIntensityScale.addSelectionListener(widgetSelectedAdapter(e -> {
+ toolSettings.airbrushIntensity = airbrushIntensityScale.getSelection();
+ updateToolSettings();
+ }));
}
/**
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/paint/PaintSurface.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/paint/PaintSurface.java
index 188dfab885..3cdb40d3aa 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/paint/PaintSurface.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/paint/PaintSurface.java
@@ -10,12 +10,12 @@
*******************************************************************************/
package org.eclipse.swt.examples.paint;
+import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;
+
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
@@ -167,20 +167,10 @@ public class PaintSurface {
/* Set up the paint canvas scroll bars */
ScrollBar horizontal = paintCanvas.getHorizontalBar();
horizontal.setVisible(true);
- horizontal.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- scrollHorizontally((ScrollBar)event.widget);
- }
- });
+ horizontal.addSelectionListener(widgetSelectedAdapter(event -> scrollHorizontally((ScrollBar)event.widget)));
ScrollBar vertical = paintCanvas.getVerticalBar();
vertical.setVisible(true);
- vertical.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- scrollVertically((ScrollBar)event.widget);
- }
- });
+ vertical.addSelectionListener(widgetSelectedAdapter(event -> scrollVertically((ScrollBar)event.widget)));
handleResize();
}

Back to the top