Hi Anton,

in this respect ULCComboBox behaves much like Swing:
If you set editable = true for a JComboBox then the JComboBox
activate the combo box editor for the current selection. This is
normally a text field without borders and the latter text field
gets the focus. So for Swing, you would have to add a focus listener
on the combo box editor as well. You can get access to the editor
by saying JComboBox.getEditor().

The story for ULC is very similar, except the you cannot access
the default editor on the server-side because it is not available
to the ULCComboBox instance. However ULC allows you to set an ULCComboBox
editor too (on the server-side) and the latter allows for Server-side
access.

The following little demo program from below illustrates how you do this for
ULC.

One thing to note is that the manually set editor does not automatically
select the editable text. If you wanted this to happen too, I guess you
should
best write a corresponding extension of ULCTextField.

public class ComboBoxTest extends AbstractApplication {
    public void start() {
        final ULCTextField textField = new ULCTextField();
        textField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));

        ULCComboBox comboBox = new ULCComboBox();
        comboBox.addItem("One");
        comboBox.addItem("Two");
        comboBox.addItem("Three");
        comboBox.addItem("Four");
        comboBox.addItem("Five");
        comboBox.addItem("Six");
        comboBox.addItem("Seven");
        comboBox.addItem("Eight");
        comboBox.setMaximumRowCount(5);
        comboBox.setEditor(new IComboBoxEditor() {
            public com.ulcjava.base.application.IEditorComponent
getEditorComponent() {
                return textField;
            };
        });
        comboBox.setEditable(true);
        textField.addFocusListener(new IFocusListener() {
            public void
focusGained(com.ulcjava.base.application.event.FocusEvent event) {
                System.out.println("Editor focus gained.");
            };

            public void
focusLost(com.ulcjava.base.application.event.FocusEvent event) {
                System.out.println("Editor focus lost.");
            };
        });

        comboBox.addFocusListener(new IFocusListener() {
            public void
focusGained(com.ulcjava.base.application.event.FocusEvent event) {
                System.out.println("Focus gained.");
            };

            public void
focusLost(com.ulcjava.base.application.event.FocusEvent event) {
                System.out.println("Focus lost.");
            };
        });

        ULCBoxPane boxPane = new ULCBoxPane(1, 2);
        boxPane.add(ULCBoxPane.BOX_EXPAND_TOP, comboBox);
        boxPane.add(ULCBoxPane.BOX_EXPAND_EXPAND, new ULCFiller());
        boxPane.add(new ULCButton("Hello"));

        ULCRootPane rootPane = createRootPane();
        rootPane.add(boxPane);

        rootPane.setVisible(true);
    }

    protected ULCRootPane createRootPane() {
        ULCFrame frame = new ULCFrame();
        frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);
        frame.setTitle("Combo Box Extension Example");
        frame.setSize(400, 300);

        return frame;
    }
}


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Anton Zanchenko
Sent: Montag, 17. Juli 2006 18:12
To: [email protected]
Subject: [ULC-developer] ULCComboBox eventing issue


Hello!

I'm working with Combo Box (ULC 6.1) and recently met following problem.
When I register focus listener to ULCComboBox component and make
setEditable(true) focus listener doesn't receive any events.
But if make setEditable(false) for ComboBox component when registered focus
listener receives all events correctly!
Please, can you provide me with workaround? Thanks.

Regards,
Anton Z.


_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer

Reply via email to