-
Notifications
You must be signed in to change notification settings - Fork 4
/
SliderTest.java
45 lines (38 loc) · 1.6 KB
/
SliderTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package org.eclipse.swt.sliders;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Slider;
import com.xored.q7.quality.mockups.issues.BaseMockupPart;
public class SliderTest extends BaseMockupPart {
public Control construct(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL)
.grab(true, true).applyTo(composite);
GridLayoutFactory.swtDefaults().numColumns(2).applyTo(composite);
Slider slider = new Slider (composite, SWT.HORIZONTAL);
Rectangle clientArea = composite.getClientArea ();
slider.setBounds (clientArea.x + 10, clientArea.y + 10, 200, 32);
slider.addListener (SWT.Selection, new Listener () {
public void handleEvent (Event event) {
String string = "SWT.NONE";
switch (event.detail) {
case SWT.DRAG: string = "SWT.DRAG"; break;
case SWT.HOME: string = "SWT.HOME"; break;
case SWT.END: string = "SWT.END"; break;
case SWT.ARROW_DOWN: string = "SWT.ARROW_DOWN"; break;
case SWT.ARROW_UP: string = "SWT.ARROW_UP"; break;
case SWT.PAGE_DOWN: string = "SWT.PAGE_DOWN"; break;
case SWT.PAGE_UP: string = "SWT.PAGE_UP"; break;
}
System.out.println ("Scroll detail -> " + string);
}
});
return null;
}
}