Viewing events for a component

The Java Beans view shows all of the events set on the components in your visual class.

The Java Beans view has three modes for showing events:

To view the events on a component:

  1. On the Java Beans view toolbar, click the menu (arrow) button.
  2. Select Show Events or Expert Events.
    • Show Events

      When Show Events is selected, the events used by each component are shown as children in the tree. Events are marked with green arrows green arrows, property change events are marked with blue arrows blue arrow icon.

      For an event to be used by a component, there must be a registered listener, and the callback method must have some code within it. The list of recognized source code patterns used by the visual editor are described in the source code patterns for events section. In the following image, the Java Beans view shows a JFrame with a windowOpened event, and it shows a button with an actionPerformed event. The button also has a PropertyChangeListener for its enabled properties, and this is shown with a blue arrow instead of green.

      Basic Events

      Each event is made up of the source component (the JFrame or JButton in the example being used), a class that implements the listener interface that is added to the source using addXXXListener(XXXListener), and some code within the body of the callback method. 

    • Expert Events

      In the Expert Events mode, each listener for the component is shown as a child tree node, and the events are shown beneath each listener. This increases the number of items in the tree, but it shows more detail about how the events are attached to the components. The option of the two modes lets you decide which level of detail you want to work with.

      In expert mode the icon used for the listener shows the type of listener class. If the listener is an anonymous inner class that implements the listener interface, the event present icon icon is used, and if the listener is an anonymous inner class that extends a listener adapter class, the event present class icon is used.

      In addition to anonymous inner classes being used for listeners, named classes and shared listeners are also parsed and recognized by the visual editor. If the listener is not anonymous in expert mode, then the icon is gen listener icon . If the listener is shared by more than one component, the shared class object is used. If the listener class is used by a single event, then these are listed as children of the listener. However, if the listener class is used by more than one event listener interface for the component, in Expert mode these listener interfaces are shown as separate children of the listener class, as shown in the following image:
      expert events shared

      The source for this is shown in the following code statement. The inner listener class IvjEventHandler is used once by the first button (this) for a keyPressedEvent, and twice by the "Cancel" button, once for keyPressed (that is part of the key event) and another time for actionPerformed (that is part of the action event).

      class IvjEventHandler implements java.awt.event.ActionListener, java.awt.event.KeyListener {    public void actionPerformed(java.awt.event.ActionEvent e) {      
         if (e.getSource() == VCEStyle2.this.getCancelButton())     
         connEtoC3(e);   
      };    
       public void keyPressed(java.awt.event.KeyEvent e) {      
          if (e.getSource() == VCEStyle2.this.getCancelButton())     
          connEtoC2(e);   
      if (e.getSource() == VCEStyle2.this)     
          connEtoC1(e);   
      };    
       public void keyReleased(java.awt.event.KeyEvent e) {};    
       public void keyTyped(java.awt.event.KeyEvent e) {}; 
      }; 
Related concepts
Events, listeners, and adapter classes
The Java Beans view
Related tasks
Adding events to a component
Deleting events from a component
Viewing the source for an event

(C) Copyright IBM Corporation 1999, 2004. All Rights Reserved.