Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

JCombobox events

hellbringer123hellbringer123 Posts: 1Member
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

  • davitefdavitef Posts: 8Member
    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
    :


  • ammar_gamarammar_gamar Posts: 1Member
    : 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.