source: trunk/tests/SWT/java/SWT009_03.java

Last change on this file was 12, checked in by lpino, 18 years ago
  • Initial commit
File size: 2.0 KB
Line 
1/*
2 * SWT009_02.java
3 */
4
5/*
6 * Copyright (c) 2002, 2005 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
12import org.eclipse.swt.widgets.Display;
13import org.eclipse.swt.widgets.Label;
14import org.eclipse.swt.widgets.Shell;
15import org.eclipse.swt.SWT;
16import org.eclipse.swt.widgets.*;
17import org.eclipse.swt.layout.FillLayout;
18import org.eclipse.swt.graphics.*;
19
20public class SWT009_03 extends SWTTestCase {
21
22 static {
23 STEP = "009";
24 TEST = "03";
25 DESC = "List";
26 }
27
28 Shell createTopShell(Display display) {
29 return new Shell(display, SWT.SHELL_TRIM | SWT.NO_REDRAW_RESIZE);
30 }
31
32
33 void initComponents() {
34 shell.setText("Hello World List");
35 shell.setSize(300, 300);
36 final List l = new List(shell, SWT.MULTI | SWT.BORDER);
37 l.setBounds(50, 50, 75, 75);
38 l.add("Item One");
39 l.add("Item Two");
40 l.add("Item Three");
41 l.add("Item Four");
42 l.add("Item Five");
43 System.out.println("Element at index " + 1 + " = " + l.getItem(1));
44 System.out.println("Number of elements on the List = " + l.getItemCount());
45 System.out.println("Height of an element of the List = " + l.getItemHeight());
46 String[] ele = {"Item Six", "Item Seven"};
47 System.out.println("Items selected = " + l.getSelectionCount());
48 System.out.println("Index of string = " + l.indexOf("Item One"));
49// l.select(1);
50// int[] selected = {1,2,3};
51// l.removeAll();
52 l.setItems(ele);
53// l.computeSize(20,20,false);
54 shell.open();
55 }
56
57
58 void setTitle(String title) {
59 super.setTitle(title);
60 }
61
62 public static void main(String[] args) {
63 go(new SWT009_03());
64 }
65
66}
Note: See TracBrowser for help on using the repository browser.