Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Difference between Beans and Applets

463 views
Skip to first unread message

Jorge E Jaramillo

unread,
Dec 1, 1998, 3:00:00 AM12/1/98
to
I got this definition of Beans from a Sun page:
"JavaBeans extends Java's "write once - run everywhere" capability to
reusable component development. In fact, JavaBeans takes interoperability a
major step forward -- your code runs on every OS and also within any
application environment. "
Isn't this what java is about? that you send the code and also the
application to see that?
Please someone explain the difference between Applets and beans.
thanks

JeJ

Jamey Graham

unread,
Dec 2, 1998, 3:00:00 AM12/2/98
to
Hey, this one I think I can actually answer.

Applets are generally self contained -- in most cases, they don't interact
with their environement. Also, the aforementioned environment, by current
design, is generally a web browser (many of the Applet methods have no
meaning outside of a web browser). Applets also always have some graphical
representation (the class Applet is a decendent of java.awt.Panel).

The most obvious difference between a Bean and an Applet is that a Bean
isn't limited to the confines of a web page. A Bean, in fact, isn't limited
to any application or even to Java itself. In theory, you can code a Bean
(don't let me confuse you with that last sentence -- Beans are always CODED
in Java), but use it in a VisualBasic application (or a Word document, or a
Lotus Note, or a Java Applet...) This is possible because Beans has at the
core of it's architecture ways to interface with it from non-Java languages.

To a Java developer, there's little difference between a class (object) and
a component. I'd imagine the term "component" came into vogue so non-OO
languages (e.g. C or even VB) wouldn't be frightened away by them. The
common metaphor for components are Lego pieces. Each component provides
some small service that a software developer assembles with other components
to (eventually) create the application. Some services are related to the
user interface (I believe all Swing components are exposed as beans) --
other's aren't (e.g. a data access component).

The adoption of Beans has been slow, most likely because Beans are competing
with Microsoft's Component Object Model (COM; COM is the foundation for
ActiveX and a slew of other COM technologies). The fact that COM components
can be both used *and* developed in any language (plus the fact that
Microsoft has such a huge marketshare) has led to its success.

The quoted snippet sounds like it came right from the Javasoft site, so I'd
imagine you know where to look for a more detailed description of Beans
(e.g. property pages, InfoBus, EJB, etc).


To answer your subject line question:
Applets are Java's chance to position itself in a web page.
Beans are small components that provide some service to a host application
(the host application can even be an Applet).

Jorge E Jaramillo wrote in message ...

Joseph FitzGerald

unread,
Jan 7, 1999, 3:00:00 AM1/7/99
to
A JavaBean is a visually programmable reusable component. You can write an
applet using JavaBeans and never once have to write a single line (or even
fragment) of java code. I can't imagine it being a particularly useful applet,
but you can do it.

If you haven't used any visual development environments then you may still not
have a very good picture of what a JavaBean is and why they are so important.
Hmn. Well, I guess I'll try to describe one of the simple applets I mentioned
above, maybe that will help.

Picture a development system (like ones provided by Powerbuilder, Delphi...)
which lets you drag "objects" onto a "frame." By objects, I mean things like
text boxes, pull down lists, text-area boxes...standard user interface
components. By "frame" I simply mean the "box" your application will run in.

Every user interface component is a JavaBean. So picture a palette on the left
containing all of the UI components (radio buttons, submit-type buttons,
checkboxes, sliders, text boxes...). All of those components are JavaBeans.

Now we'll create the applet. You could drag a text box, a button, and a
text-area box onto the frame. You could also drag a few label objects onto the
frame so you could give these components titles. Using your mouse you could
drag these components anywhere on the screen.

Now you would select the button object you dragged onto your applet form, right
click on it, and select something like 'connect...' from the menu. This would
present a list of options, one of which would be something like
'ActionPerformed(...)', which means when the button gets pressed. Once you
selected 'ActionPerformed(...)' your cursor would turn into a new pointer and
you would move it over the text-area component and press the button. You'd now
see a dashed line between the button and the text-area component.

Now you'd right click on the text box component and select connect. From the
menu you'd select text and then using that same special pointer, you'd select
the dashed line. This sequence of events tells the system that the text
contained in the text box should be displayed in the text-area component when
the pushbutton is pressed.

If you wanted to clear the text-box component when the button was pressed (but
after the text was copied from the text-box to the text-area component) then
you would right click on the button again, select connect from the menu, select
ActionPerformed(...), and click on the text-box. Then you'd right click the
dashed line, select properties, select something like "set parameter" with the
'text' option highlighted, and make sure and make sure it had a blank value.

That's it. That is a complete applet. No hand-written code. Granted it
doesn't do a whole lot, but the point is that you can remove a lot of grunt
development work by using visual programming techniques with JavaBeans.

Oh, and don't think that only "viewable/graphical" components can be tied
together this way. You can connect accomplish much more complicated things
too.

Hopefully this explains a little bit what a JavaBean is...

Joe

0 new messages