Using Java BeanBox

Home  »  Java  »  Advance Java  »  Java Beans  »  Using Java BeanBox



  • Click the Juggler Bean in the ToolBox window and then click in the BeanBox: the Juggler Bean is placed in the BeanBox. The Bean starts juggling. The property sheet of the Juggler Bean is displayed. The Bean can be customized by changing its properties.



  • Diagram 25.3 Adding a Bean



  • To add a button to the BeanBox click an OurButton Bean in the ToolBox and then click in the BeanBox. Use the property sheet to set the following properties:

  • Property NameValue
    LabelStart
    BackgroundNote1




    Diagram 25.4 Adding a Start Button



  • In a Similar manner the Stop button is added to the BeanBox.



  • Diagram 25.5 Adding a Stop Button



  • These Start and Stop buttons have added to control the juggler's animation. For this connect the Start button's actionPerformed() event handler to the startJuggler() method of the JugglerBean and the Stop button's actionPerformed() event handler to stopJuggling() method of the Juggler Bean.

  • To achieve this Start button has to be selected and the select Edit|Event|Action|ActionPerformed, from the BeanBox member.



  • Diagram 25.6 Selecting the actionPerformed() event handler



  • As soon as this is done a line (red) is visible from the Start button. This line represents the logical connection from the Start button's actionPerformed() event handler to the Juggler. Click inside the Juggler Bean to close the connection.



  • Diagram 25.7 Connecting the event handler to the Juggler



  • On doing so, the EventTargetDialog Box is displayed. This dialog box lits the interface methods of the Juggler Bean. Select startJuggling() method. By doing so, the clicking of Start Button gets connected to the startJuggling() method, via the actionPerformed() event handler of the 'start' button Bean.



  • Diagram 25.8 Connecting to the start juggling method.



  • The EventTargetDialog Box notifies that it is compiling an adapter class. The BeanBox creates a special class called and adapter class, to connect the click of the Start button with the startJuggling() method of the Juggler. The BeanBox must compile this class and add it to the running BeanBox to support this connection.

  • In a similar fashion connect the click of the Stop button to the stopJuggling() method.

  • Now the Juggler is ready to act.


  • Understanding the Sample Beans

    Just to whet your appetite, what follows is a short description of the Beans that are in the ToolBox.

    Blue ButtonA simple button with background, foreground, label and font properties.
    Orange ButtonA simple button with background, foreground, label and font properties.
    Out ButtonA grey button with additional font properties.
    Explicit ButtonA simple button with background, foreground, label and font properties.
    Jelly BeanA simple visual component that draws a colored oval "jelly bean".
    VoterDesigned to handle a vetoableChange event. By default the Bean will reject all change requests, but change requests will be accepted if the vetoAll property is set to false.
    ChangeReporterA textfiled.
    MoleculeSimilar to Juggler in concept. The Bean displays a 3-D representation of a molecule and accepts mouse input to rotate the molecule.
    QuoteMonitorUses RMI to contact a remote (or local) quote server and request a real or imaginary stock quote value.
    JDBC SelectUses the JDBC API to connect to a database at a specified URL and issue a select statement.
    BridgeTesterProvides a set of property types and events that may be used to test other bean components.




    Java Beans Programming




4 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Good Post! Thank you so much for sharing the post, it was so good to read and useful to improve
    Java Training in Electronic City

    ReplyDelete
  3. Thank you for sharing useful information with us. please keep sharing like this. And if you are searching a unique and Top University in India, Colleges discovery platform, which connects students or working professionals with Universities/colleges, at the same time offering information about colleges, courses, entrance exam details, admission notifications, scholarships, and all related topics. Please visit below links:

    Manav Rachna International Institute of Research and Studies Faridabad

    NIMS University Jaipur

    Nirma University Ahmedabad

    PES University Bangalore

    Rabindranath Tagore University Bhopal

    ReplyDelete