[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools] Re: SWT Combo question


Pressing the ENTER key is the default selection mechanism for a Combo widget.
Run the folowing example and hit ENTER - you should see the message "Default Selection occurred" printed to the console:

public static void main (String [] args) {
        Display display = new Display ();
        Shell shell = new Shell (display);
        Combo combo = new Combo(shell, SWT.NONE);
        combo.add("a");
        combo.add("b");
        combo.add("c");
        combo.add("d");
        combo.setBounds(10, 10, 200, 40);
        combo.addSelectionListener(new SelectionAdapter() {
                public void widgetDefaultSelected(SelectionEvent e) {
                        System.out.println("Default Selection occurred");
                }
        });
        shell.open ();
        while (!shell.isDisposed ()) {
                if (!display.readAndDispatch ()) display.sleep ();
        }
        display.dispose ();
}