Now you can define some event (Unlimited web hosting) processing for
Now you can define some event processing for the new button. Right-click the selected button. In the context menu choose Events, and in the cascading submenu select actionPerformed. Now, sit back and watch how the source code for this event is generated: jButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { System.out.println(”actionPerformed()”); // TODO Auto-generated Event stub actionPerformed() } }); If you now run the program again after saving it, the text actionPerformed() appears in the Console View when you click OK. The Events submenu, however, lists only the most relevant events for a component. Other event types can be reached via the Add Event function. For example, if you want to react to the resizing of components, you need to invoke the Events > Add Event … context function. In the dialog that appears, expand the Component class. Then select the componentResized event type. Finally, you may specify whether a subclass of the ComponentAdapter class is to be generated or whether a complete implementation of the ComponentListener interface is to be generated. Afterwards, you can complete the definition of the componentResized() method in the source code area as needed. This concludes our short introduction into the Eclipse Visual Editor. In Chapter 5 I will demonstrate the VE in the design of a more complex GUI in the context of a larger application. Summary This chapter has given you a glimpse of the Eclipse Visual Editor. Novices especially often find it easier to design GUI surfaces visually. Currently the Eclipse Visual Editor supports only Swing GUIs. If you need help creating SWT GUIs (see Chapter
, you still have to rely on third-party GUI designers, some of which are listed in Appendix A. Another possibility is to use the SWT Layout example plug-in as a code generator. In the next chapter we will take a more detailed look into the Eclipse workbench. 50 Chapter 3
Would you like to be a member of headache free web site owner’s community. Now you can. We focus in IX Web Hosting, go go go!