⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 14.htm

📁 翁剀JAVA语言那门课程的教案 很多人都看多他的视频教程可惜没有ppt的教案
💻 HTM
字号:
<HTML>
<HEAD>
   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
   <META NAME="Author" CONTENT="Weng Kai">
   <META NAME="GENERATOR" CONTENT="Mozilla/4.01 [en] (Win95; I) [Netscape]">
   <TITLE>Visual programming and Beans</TITLE>
</HEAD>
<BODY>

<H1>
14. Visual programming and Beans</H1>

<HR WIDTH="100%">
<BR><IMG SRC="beans.gif" HEIGHT=177 WIDTH=203 ALIGN=LEFT>So far in this
book you've seen how valuable Java is for creating reusable pieces of code.
The "most reusable" unit of code has been the class, since it comprises
a cohesive unit of characteristics (fields) and behaviors (methods) that
can be reused either directly via composition or through inheritance.

<P>Inheritance and polymorphism are essential parts of object-oriented
programming, but in the majority of cases when you're putting together
an application, what you really want is components that do exactly what
you need. You'd like to drop these parts into your design like the electronic
engineer puts together chips on a circuit board (or even, in the case of
Java, onto a Web page). It seems, too, that there should be some way to
accelerate this "modular assembly" style of programming.

<P>"Visual programming" first became successful -- very successful -- with
Microsoft's Visual Basic (VB), followed by a second-generation design in
Borland's Delphi (the primary inspiration for the Java Beans design). With
these programming tools the components are represented visually, which
makes sense since they usually display some kind of visual component such
as a button or a text field. The visual representation, in fact, is often
exactly the way the component will look in the running program. So part
of the process of visual programming involves dragging a component from
a pallet and dropping it onto your form. The application builder tool writes
code as you do this, and that code will cause the component to be created
in the running program.

<P>Simply dropping the component onto a form is usually not enough to complete
the program. Often, you must change the characteristics of a component,
such as what color it is, what text is on it, what database it's connected
to, etc. Characteristics that can be modified at design time are referred
to as properties. You can manipulate the properties of your component inside
the application builder tool, and when you create the program this configuration
data is saved so that it can be rejuvenated when the program is started.
By now you're probably used to the idea that an object is more than characteristics;
it's also a set of behaviors. At design-time, the behaviors of a visual
component are partially represented by events, meaning "Here's something
that can happen to the component." Ordinarily, you decide what you want
to happen when an event occurs by tying code to that event.

<P>Here's the critical part: the application builder tool is able to dynamically
interrogate (using reflection) the component to find out which properties
and events the component supports.&nbsp; Once it knows what they are, it
can display the properties and allow you to change those (saving the state
when you build the program), and also display the events. In general, you
do something like double clicking on an event and the application builder
tool creates a code body and ties it to that particular event. All you
have to do at that point is write the code that executes when the event
occurs.

<P>All this adds up to a lot of work that's done for you by the application
builder tool. As a result you can focus on what the program looks like
and what it is supposed to do, and rely on the application builder tool
to manage the connection details for you. The reason that visual programming
tools have been so successful is that they dramatically speed up the process
of building an application -- certainly the user interface, but often other
portions of the application as well.
<BR>
<HR WIDTH="100%">
<DIV ALIGN=right><A HREF="14_1.htm">Next Page</A></DIV>

</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -