Results 1 to 1 of 1
Thread: Demonstration of PopupList
-
Demonstration of PopupList
Java Code:import org.eclipse.swt.SWT; import org.eclipse.swt.custom.*; import org.eclipse.swt.events.*; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; /** * This class demonstrates PopupList */ public class PopupListTest { // These are the options that display in the list private static final String[] OPTIONS = { "Apple", "Banana", "Cherry", "Doughnut", "Eggplant", "Filbert", "Greens", "Hummus", "Ice Cream", "Jam"}; /** * Runs the application */ public void run() { Display display = new Display(); Shell shell = new Shell(display); shell.setText("PopupList Test"); createContents(shell); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); } /** * Creates the main window's contents * * @param shell the main window */ private void createContents(final Shell shell) { shell.setLayout(new RowLayout()); // Create a button to launch the list Button button = new Button(shell, SWT.PUSH); button.setText("Push Me"); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Create a list PopupList list = new PopupList(shell); // Add the items to the list list.setItems(OPTIONS); // Open the list and get the selected item String selected = list.open(shell.getBounds()); // Print the item to the console System.out.println(selected); } }); } /** * The application entry point * * @param args the command line arguments */ public static void main(String[] args) { new PopupListTest().run(); } }"The sole cause of man’s unhappiness is that he does not know how to stay quietly in his room." - Blaise Pascal
Similar Threads
-
SWT List Example Demonstration
By Java Tip in forum SWTReplies: 0Last Post: 07-02-2008, 08:03 PM -
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 -
Demonstration of drawing an Arc in SWT
By Java Tip in forum SWTReplies: 0Last Post: 06-28-2008, 09:24 PM -
Ftp client demonstration
By Java Tip in forum java.netReplies: 0Last Post: 04-07-2008, 08:11 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks