Hi all,
yes still a question about the API! I am looking into event handling at the moment (basic things with text fields, checkboxes etc ) and I have noticed that different components generates different events which are in turn handled by different objects. As an example,let's take a checkbox. When a users makes a selection, the check box generates a ItemEven which is handled by a ItemListener. Now, I obviously will never know what component generates which event (and which object handles that event), so I presume that the best way to know that is looking up on the API. I did just that but there is nowhere here http://docs.oracle.com/javase/7/docs/api/javax/swing/JCheckBox.html saying that when a user interacts with a checkbox an ItemEvent occurs. How am I supposed to know/ find out that? and where?
thanks

There is somewhere on Oracles site a table that shows which components generate which events, but I can't remember where exactly. Otherwise, look at the addXXXListener methods for your component (don't forget to look for inherited methods as well)

  • EventHandler can do that, there you can to wrap a few events together, required excelent knowledge about Java Essential Classes, Swing and AWT Listeners, there/this (never tried) maybe doesn't works for Beans with PropertyChangeListener, PropertySupport, this info can be probably out of scope for you

  • every Listener (excluding non_shareable DocumentListener) returns Object, then everything about JComponent fired an Event

  • most of AWT/Swing Listeners firing more that one event, ItemListener always firing two events SELECTED and DESELECTED, you have to test for this indicator

thanks, I think I will look for this table then because 1)there are no events there, 2) looking up the method seems a bit confusing, for example, for the JCheckBox there are a few addxxxListener methods and also - as you suggested - the inherited ones, and I am not sure which one it is that I can/should use.
thanks

oh fantastic, thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.