1 / 18

JavaBeans Workshop

JavaBeans Workshop. Working with BeanBox Example1: The Juggler Starting and Stoping juggling with two buttons Example2: A ThermoBean Raising and lowering a temperature with two buttons. Building a simple Java bean ColorPanelBean. Activating the BeanBox. Go to directory “c:bdkbeanbox”.

bono
Download Presentation

JavaBeans Workshop

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JavaBeans Workshop • Working with BeanBox • Example1: The Juggler • Starting and Stoping juggling with two buttons • Example2: A ThermoBean • Raising and lowering a temperature with two buttons. • Building a simple Java bean • ColorPanelBean

  2. Activating the BeanBox • Go to directory “c:\bdk\beanbox”. • Issue the command “run.bat”.

  3. Example 1: The Juggler

  4. Creating a Juggler • Select item Juggler from menu ToolBox. • Place the Juggler on the BeanBox.

  5. Adding Control Buttons • Place two buttons on the BeanBox. • Specify the properties of the buttons with a Property Sheet.

  6. Example 1: The Juggler • Select event to be performed on Start button

  7. Example 1: The Juggler • Choose event target --> Juggler

  8. Example 1: The Juggler • Choose target method --> startJuggler

  9. Example 1: The Juggler • How to stop the Juggler • Select event to be performed on Stop button • Choose event target --> Juggler • Choose target method --> stopJuggler • Juggler Example is ready to be tested!

  10. Example 2: The ThermoBean • Import customized bean --> ThermoBean • Select LoadJar and the choose Thermo.jar in \workshop

  11. Example 2: The ThermoBean • New bean are already to be used!

  12. Example 2: The ThermoBean • Raise Temperature • Select event to be performed on Raise button • Choose event target --> Thermo • Choose target method --> stopJuggler • Lower Temperature • Select event to be performed on Lower button • Choose event target --> Thermo • Choose target method --> stopJuggler

  13. Example 2: The ThermoBean

  14. Creating and Testing the Simplest Bean • Create a SimplestBean.java source file • Create a Manifest file Name: SimplestBean.class Java-Bean: True • Build SimplestBean.class • Pack them to .jar file • jar -cvfm <SimpleBean.jar> <Manifest file> <SimplestBean.class> • It’s ready to import to BeanBox or Other Tools

  15. What are we going to create? • A simple bean that change Red Value through a scrollbar names PanelBean.java

  16. ScrollbarBean: Bound Properties Scrollbar • Simple scrollbar extends from java.awt.Scrollbar • Add some methods to support Bound Properties in Java Beans • Use event PropertyChange to notify other beans

  17. Hint: Creating PanelBean.java • PanelBean must extend from java.awt.Panel • Support getter/setter its property --> redValue • Color of the panel can be set using setBackground(new Color(Red, Green, Blue)); • Use Bound Properties: hence must implement java.beans.PropertyChangeListener • Method public void propertyChange(PropertyChangeEvent e) must be implemented

  18. More Information • “Core JAVA Volume II-Advanced Features”, Sun Microsystems Press. • http://java.sun.com

More Related