1 | /*
|
---|
2 | * SWT009_09.java
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (c) 2002, 2007 EclipseOS2 Team.
|
---|
7 | * This file is made available under the terms of the Common Public License v1.0
|
---|
8 | * which accompanies this distribution, and is available at
|
---|
9 | * http://www.eclipse.org/legal/cpl-v10.html
|
---|
10 | */
|
---|
11 |
|
---|
12 | import org.eclipse.swt.widgets.Display;
|
---|
13 | import org.eclipse.swt.widgets.Shell;
|
---|
14 | import org.eclipse.swt.SWT;
|
---|
15 | import org.eclipse.swt.widgets.*;
|
---|
16 | import org.eclipse.swt.layout.FillLayout;
|
---|
17 | import org.eclipse.swt.graphics.*;
|
---|
18 |
|
---|
19 | public class SWT009_09 extends SWTTestCase {
|
---|
20 |
|
---|
21 | static {
|
---|
22 | STEP = "009";
|
---|
23 | TEST = "09";
|
---|
24 | DESC = "Scale";
|
---|
25 | }
|
---|
26 |
|
---|
27 | Shell createTopShell(Display display) {
|
---|
28 | return new Shell(display, SWT.SHELL_TRIM | SWT.NO_REDRAW_RESIZE);
|
---|
29 | }
|
---|
30 |
|
---|
31 |
|
---|
32 | void initComponents() {
|
---|
33 | final Scale scaleH = new Scale(shell, SWT.NULL);
|
---|
34 | Scale scaleV = new Scale(shell, SWT.VERTICAL);
|
---|
35 | //
|
---|
36 | scaleH.setBounds(0, 0, 100, 50);
|
---|
37 | scaleV.setBounds(0, 50, 50, 100);
|
---|
38 | //
|
---|
39 | System.out.println("Increment: " + scaleH.getIncrement());
|
---|
40 | scaleH.setSelection(10);
|
---|
41 | System.out.println("Get Selection: " + scaleH.getSelection());
|
---|
42 |
|
---|
43 | Point p = scaleV.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
|
---|
44 | System.out.println("width = " + p.x + " hight = " + p.y);
|
---|
45 |
|
---|
46 | scaleH.setMaximum(800);
|
---|
47 |
|
---|
48 | scaleH.addListener(SWT.Selection, new Listener() {
|
---|
49 | public void handleEvent(Event event) {
|
---|
50 | System.out.println("Scroll detail -> " + scaleH.getSelection());
|
---|
51 | }
|
---|
52 | });
|
---|
53 |
|
---|
54 | shell.pack();
|
---|
55 | shell.open();
|
---|
56 |
|
---|
57 | }
|
---|
58 |
|
---|
59 |
|
---|
60 | void setTitle(String title) {
|
---|
61 | super.setTitle(title);
|
---|
62 | }
|
---|
63 |
|
---|
64 | public static void main(String[] args) {
|
---|
65 | go(new SWT009_09());
|
---|
66 | }
|
---|
67 |
|
---|
68 | }
|
---|