Results 1 to 1 of 1
Thread: SWT List Example Demonstration
-
SWT List Example Demonstration
Java Code:import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.Shell; /** * @author Steven Holzner * */ public class SWTListExampleDemo { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("List Example"); shell.setSize(300, 200); shell.setLayout(new FillLayout(SWT.VERTICAL)); final List list = new List(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); for (int loopIndex = 0; loopIndex < 100; loopIndex++) { list.add("Item " + loopIndex); } list.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent event) { int[] selections = list.getSelectionIndices(); String outText = ""; for (int loopIndex = 0; loopIndex < selections.length; loopIndex++) outText += selections[loopIndex] + " "; System.out.println("You selected: " + outText); } public void widgetDefaultSelected(SelectionEvent event) { int[] selections = list.getSelectionIndices(); String outText = ""; for (int loopIndex = 0; loopIndex < selections.length; loopIndex++) outText += selections[loopIndex] + " "; System.out.println("You selected: " + outText); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }"The sole cause of man’s unhappiness is that he does not know how to stay quietly in his room." - Blaise Pascal
Similar Threads
-
Demonstration of the FileDialog
By Java Tip in forum SWTReplies: 0Last Post: 07-02-2008, 07:54 PM -
Demonstration of animation in SWT
By Java Tip in forum SWTReplies: 0Last Post: 06-28-2008, 09:27 PM -
SWT Draw 2D Demonstration
By Java Tip in forum SWTReplies: 0Last Post: 06-28-2008, 09:22 PM -
TreeCellRenderer Demonstration
By Java Tip in forum javax.swingReplies: 0Last Post: 06-27-2008, 07:41 PM -
Demonstration of heaps
By Java Tip in forum java.langReplies: 0Last Post: 04-14-2008, 08:50 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks