JCombobox events

Hi!

I want to react when the user enters text in a jcombobox (as soon as he enters the first character). He should not have to confirm his input by pressing enter or clicking in another component.

I already tried keyReleased, propertyChange, etc. but nothing worked.

I hope anyone can help
thx martin

Comments

  • From JDK Help:
    "
    Although JComboBox inherits methods to register listeners for low-level events -- focus, key, and mouse events, for example -- we recommend that you don't listen for low-level events on a combo box. Here's why: A combo box is a compound component -- it is comprised of two or more other components. The combo box itself fires high-level events such as action events. Its subcomponents fire low-level events such as mouse, key, and focus events. The low-level events and the subcomponent that fires them are look-and-feel-dependent. To avoid writing look-and-feel-dependent code, you should listen only for high-level events on a compound component such as a combo box.
    "

    From tutorial:
    "
    Problem: My combo box [PENDING: other compound components?] isn't generating focus, [PENDING: list of other low-level events here] events.
    Blah blah blah compound component blah blah blah low-level events.
    "

    It's a Java problem!

    : Hi!
    :
    : I want to react when the user enters text in a jcombobox (as soon as he enters the first character). He should not have to confirm his input by pressing enter or clicking in another component.
    :
    : I already tried keyReleased, propertyChange, etc. but nothing worked.
    :
    : I hope anyone can help
    : thx martin
    :


  • : Hi!
    :
    : I want to react when the user enters text in a jcombobox (as soon as
    : he enters the first character). He should not have to confirm his
    : input by pressing enter or clicking in another component.
    :
    : I already tried keyReleased, propertyChange, etc. but nothing
    : worked.
    :
    : I hope anyone can help
    : thx martin
    :
    :
    hi i have the same problem and i think the interface javax.swing.JComboBox.KeySelectionManager is maybe the solution to this problem, see how to implemenet it
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories