Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

Actions

Actions are an elementary part of a user interface. Actions shall be executed in reaction to an event triggered by the user. Such an event can be a mouse click or pressing a key, for example. You can define an individual action for each event of a component. The GUI Builder connects event and action for you. You can choose from all available events in the context menu (Events). Clicking a certain event, a listener is automatically registered for it. This listener calls the method. Then you can implement its body in the Source view.

An example will illustrate this. An action will be implemented for the actionPerformed event (so clicking on the button) for the button shown in Figure 41-5. This is why you call the following entry out of the context menu of the button jButton1: Events Image Action Image actionPerformed. The editor automatically changes into the Source view and jumps into the referring method which is called with this event. In Listing 41-1 it is the method jButton1ActionPerformed().


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial