Hi all, as much as I don't like the API, it is becoming more and more important for me to start using it. I think I might need a guide of some sort which says what's what and what's where, if anybody has one please let me know.
Today I was tyring to find out what events a component supports. I looked up the
JTextField component http://docs.oracle.com/javase/7/docs/api/javax/swing/JTextField.html but I couldn't find anywhere an "event" section - unless I am doing something wrong which is quite likely. Anyway, where do I find the kind of events that components support? Like in the above case, where in the API do I find what events
You can look at its addXxxListener methods to see which events it will give callbacks for. Don't forget to check all the superclasses as well.
JTextField has addActionListener
then scroll down a screen or two to find
addCaretListener, addInputMethodListener inherited from JTextComponent
addAncestorListener, addVetoableChangeListener from JComponent
addContainerListener, addPropertyChangeListener from Container
addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener from Component
Thast has to be the complete set of events because there are no methods to add any other kind of listener to a JTextField.
Tedious? Yes, it is. We all have a love/hate relationship with the API doc, especially when you have to search mutliple superclasses to find all the applicable methods. However, you can't write Java without it, so ...
ps Having given the general answer, here's a pretty useful summary for the most common JComponents/events