The IDE relieves you of the task of providing the infrastructure required around event handling by generating the code to link the occurrence of the event with the invocation of a private method in the form class. For example, a JButton named myBtn might have the code myBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { myBtnActionPerformed(evt); } added to its initialization, where the method myBtnActionPerformed is generated as: private void myBtnActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }
Generation of this event infrastructure code can be done in a few different ways:
To use the Connection wizard:
Figure 6-10. Connection Wizard, Specify Target Operation pageThe Connection Wizard approach is simply a "point and click" approach to the task. The code generated by the wizard is not guarded and can be modified in the editor after generation. |