For this assignment, you are to write a JavaBean class, and then load it into the beanbox and use it in some way to make a new bean as appropriate:
either set some properties or link some button events to methods in the bean.
Here are two ideas of beans that you might write:
You are to take an existing code with a visualization such as the
Bouncing Ball shown in class. Make it into a bean,
have methods that can be the target of events, and use it in the beanbox to make a new bean with buttons.
A few ideas:
This idea is to make a bean that lets you draw a presentation slide with a title and several bullets. The text in the title and bullets can have properties like font and color. Here are two ideas about how to do this, but you may have others.
One way to do this is to work from something like the hotspots example or the graph? example to have a canvas where you can draw text. (You don't need to implement drawing shapes as well.) Each time that you changed the properties, you could place a new title or bullet on the canvas (without erasing the old ones!) Also, you can keep it simple by just having the properties refer to the current text, which has the drawback that you can't go back and edit the title or other bullets that you have already placed.
Another way to do this would be to have two beans: title and bullet that extend Canvas and just place one piece of text on the bean area. This has the advantage that you can select individual texts and edit them. But it's not as nice as far as packaging a slide on one canvas. The way to get a slide is to save the whole thing as a new bean.
Bounce ball Java Bean
is an example that demonstrates how Java's component architecture works. In this example, we use BDK
(JavaBean's Development Kit), as the graphical programming environments, to configure components --
Bounce ball
Java Bean and
ExplicitButton
Java Bean-- by specifying aspects of their visual appearance, in addition to the interactions
between these components. This means that we can make an application -- Bounce ball bean with button control
-- without actually writing any Java code when we have all the components made.
Back to Top Page
Properties of bouncing ball bean
Two hooked up Buttons
OPEN
and
STOP
are methods used for building up connection to ExplicitButton Bean, which controls starting and
resuming of the animation of the bouncing ball.
Properties of the bouncing ball
bounceBallColor
is the property field used for changing the color of bouncing ball.
fontSize
is the property field used for changing the size of signature.
bounceBallSize
is the property field used for changing the size of bouncing ball.
ballInitpositionX
is the property field used for setting the staring bouncing x-position.
ballInitpositionY
is the property field used for setting the staring bouncing y-position.
animationRate
is the property field used for changing the speed of bouncing.
ballWidth
is the property field used for setting the width of bouncing ball.
ballHeight
is the property field used for setting the height of bouncing ball.
Shape
is the property field used for changing the shape (ecllips or rectangle) of bouncing.
- Source Code :
Bounce.java
bounce.mk
Bounce.jar
- Demo :
Copy Bounce.jar to BDK/jars/ and load in Beanbox on PC (Windows).
The demo Bounce.jar is coded and tested with
Netscape Communicator versions 4.5, 4.04
with AWT 1.1 patch on
PC (Windows).
To run the demo, Copy Bounce.jar to BDK/jars/ and load it into Beanbox.
In order to run the bean -- Bounce.jar on a workstation, the following steps have to be executed:
Note
It is unable to test most of the property features of the original bean after it has been hooked up with ExplicitButton bean and generated
into a new bean.
Back to Homework Page