THE GREAT IDE ROUNDUP
PowerJ
Is Ready for Swing
Sybase
has unveiled PowerJ Enterprise 2.5, the most Swing-ready release
to date of a powerful JavaTM-language
IDE.
When you install PowerJ Enterprise 2.5, Swing is installed automatically.
When you start PowerJ, Swing component set is neatly integrated
into the IDE´s design environment.
PowerJ
2.5 also boasts a number of other new features, including the integration
of two useful programming tools from Sybase: PowerSite (a
complete RAD environment for creating, managing, and deploying web
applications), and AppModeler (a tool for leveraging database
models to generate customizable objects, web-based objects, and
data-aware components.)
PowerSite, previously available as a separate product, is
a comprehensive Web development and tool. PowerSite includes HTML
and script editors; a component manager; a role-based security tool;
and an HTML implementation of Sybase DataWindowTM
technology. (In the Sybase programming environment, a DataWindow
is a window that can extract data and display it in a variety of
formats.)
AppModeler is a database-modeling and database-generation
tool. With AppModeler, you can design database models, generate
test data, generate and maintain databases, and transfer modeling
information to and from development-tool dictionaries.
You can learn much more about these new additions to PowerJ Enterprise
by visiting the Sybase PowerJ
Web site.
About PowerJ 2.5
Sybase says PowerJ
Enterprise is designed to be more than a conventional IDE. It is
billed by Sybase as "a comprehensive environment for developing
distributed Web and client-server applications with the JavaTM
programming language, HTML, and JavaScript."
Software that Comes with PowerJ
To underline this claim, PowerJ supplies customers with
a generous supply of supporting software, including:
- SQL Anywhere: A special three-user version of Sybase's
SQL Anywhere relational database system.
- Sybase jConnect for JDBC: Sybase's 100% Pure JavaTM
implementation of JDBC (Java Database Connectivity).
- Jaguar CTS: a component transaction server for what Sybase
calls a "new breed of business solutions" -- high-speed OLTP applications
that can be used over the Internet as well as in traditional corporate
networks.
- ObjectCycle: a version-control tool for managing software
components in a team setting.
- Infobase: A CD-ROM guide to reference data about
Sybase products. Infobase is published by Sybase and is updated
quarterly. The PowerJ 2.5 package includes a free copy of the
latest Infobase CD-ROM.
The Enterprise Application Studio
The PowerJ Enterprise IDE is part of a product suite called
the Enterprise Application Studio, which Sybase calls "a
new breed of customer-centric computing." Along with PowerJ, the
Enterprise Application Studio includes the following products (not
supplied with PowerJ but available separately):
- The Sybase Enterprise Application server.
- PowerBuilder Enterprise (a C++-based IDE).
- PowerBuilder Enterprise, a 4GL development tool.
- PowerJ Enterprise, a RAD tool based on the Java programming
language platform.
For more details on the Enterprise Application Studio and the support
software that comes with PowerJ, visit the Sybase PowerJ
Web site.
How PowerJ 2.5 supports Swing
As
this issue of The Swing Connection went online, Sybase released
newest version of PowerJ -- Version 2.5 -- which enhances the Swing
support that was available in earlier versions of the product.
As
soon as you start PowerJ Enterprise 2.5, component palette containing
a tabbed page of Swing components appears at the top of the IDE´s
main window. If you want to use Swing components in your program,
just tab to the Swing component palette, and you´re ready to go.
This
is just part of PowerJ´s Swing component palette:
With
PowerJ, you can edit the properties of components -- including Swing
components -- using a standard-style Object Inspector. You can set
component properties programmatically, or you can use a propriety
PowerJ tool called a reference
card.
(In
the PowerJ environment, a reference card is a mechanism that simplifies
the adding of custom code to code generated by the PowerJ IDE) .
With
Version 2.5 of PowerJ, you can derive programs from the usual Swing
classes: JApplet, JApplication, JFrame, JPanel, and JDialog. Two
different kinds of Swing-based JDialog forms -- for modal and modeless
dialogs -- are available.
Other
new features that support Swing in PowerJ 2.5 include drag-and-drop
programming and a set of wizards for setting method parameters.
PowerJ's screen display
PowerJ comes equipped
with the standard ingredients of any full-featured integrated IDE,
plus a collection of proprietary tools that are unique to the PowerJ
development environment. Unlike some IDEs, which display just one
master window, the PowerJ display is made up of separate windows
that you can move around and even display individually by choosing
menu items. Here's a typical group of windows, including PowerJ's
main menu/toolbar (top) and a design form (lower right):
Like most IDEs, PowerJ is equipped with a design form, a built-in
source-code editor, a full complement of property sheets (called
object inspectors in the PowerJ environment), a built-in compiler,
and a built-in debugger.
PowerJ's object inspector window is equipped with two tabbed pages:
one that you can use to set properties, and one that you can use
to configure your program's response to events. This is what an
object inspector window looks like in PowerJ:
The PowerJ reference card
PowerJ is equipped
with a set of wizards that are designed to help you perform common
tasks, and a "reference card" that can simplify the job of inserting
event handlers or other kinds of specialized code into an applet
or an application. Here's a screen shot of the PowerJ reference
card:
To use the PowerJ reference card, you simply drag an object from
the PowerJ form designer into the IDE's source-code editor. The
reference card then opens automatically. As you drag over the code
editor, the insertion point moves to show you where your code will
be inserted when you stop dragging.
The PowerJ reference card lists all the actions (or methods) that
you can perform using the object that you have dragged into the
code window. When you choose a method from the reference card, a
Parameter Wizard opens to help you fill in parameters for
the method you have chosen. When you fill in parameters and close
the Parameter Wizard, PowerJ automatically inserts the appropriate
code into the applet or application you are developing.
PowerJ´s reference card is a great learning tool and can be quite
helpful in writing routine code. But Sybase acknowledges in its
PowerJ documentation that you´ll often need to write customized
code to supplement the work you do with the reference card. We applaud
Sybase for recognizing that need, and for making it easy for use
to insert hand-written code into the code that PowerJ generates.
Power programmers who hate IDEs that try to do too many things automatically
should try out PowerJ; our impression is that it gets the balance
between automation and freedom to program just about right.
Creating a Swing applet
To
start the process of creating an applet or an application in PowerJ,
you select the File|New|Target command from the IDE's main
menu. A Target Wizard then opens to help you set up your
applet. With the Target Wizard, you can the select the kind of target,
or program, that you want to create.
With PowerJ 2.5, you can choose from several
different target types. For
example, if you want to create a Swing applet -- that is, and applet
derived from Swing's JApplet class -- you can choose the JApplet
target type by selecting an icon labeled "JFC Applet," as shown
in this screen shot:
To evaluate PowerJ's Swing-readiness for
this report, we selected the JFC Applet to create a Swing applet.
When we clicked the Next button, the wizard let us choosed a name
and a location for the project that we were about to create.
Creating a Swing applet
To
see how PowerJ works with Swing, we decided to develop a simple
applet modeled after one you may have seen elsewhere in The Swing
Connection. When the applet starts, it displays a figure of
the JavaTM mascot, Duke, merrily
swinging and waving at you from a swing. Below Duke's picture there´s
a toggle button that says, "Stop!" When you click it, Duke stops
swinging. Click it again, and he starts swinging again.
The original version of the Swinging Duke program was created by
hand, without the help of any IDE. In Part 2 of the "Getting
Started with Swing" article in this issue, you can
find a complete source listing of the program, along with a set
of step-by-step hands-on instructions that explain how to build
it.
Placing components on a design form
To create a custom version of the Swinging Duke applet
using PowerJ, we opened the Target Wizard and selected the JFC Applet
icon, as shown in the screen shot in
the previous section. Then we used the mouse to reduce the size
of PowerJ's design form to the size we wanted to use for our applet.
That done, we navigated to PowerJ´s Standard component palette
and placed a "PictureBox" component on our design form. Then we
tabbed to the Swing component set and placed a JToggleButton component
just beneath our picture box.
We decided to display Duke´s picture inside a PictureBox component
because an ImageIcon component doesn´t appear on PowerJ's component
palette -- an understandable omission, since the ImageIcon class
provided in Swing 1.0.x (which PowerJ uses) is afflicted
with a bug that prevents its constructor from loading images properly.
Avoiding this bug requires an annoying workaround, so it was simpler
to go ahead and use PowerJ´s PictureBox component. (For details,
see the source code and accompanying text provided in Part 2 of
"Getting
Started with Swing." )
To create the button that appears below Duke´s image in the
Swinging Duke program, we used a JToggleButton component because
that´s what we used in our original hand-wiritten version of the
program.
Displaying an image
To place an image of Duke inside our form´s PictureBox,
we right-clicked over our PictureBox component. A property sheet
then popped up, and we used it to specify the URL of the picture
that we wanted to display:
In this screen shot, notice that the entry in the URL text
box is an absolute URL rather than as a relative one. The PictureBox
property sheet accepts relative URLs, or even pathnames, in its
URL text field. But if you want PowerJ to display a visible
image on your form at design time, you must use an absolute URL,
as shown above.
Labeling a button
When
we had equipped our PictureBox with an initial image to display,
we tested it by choosing the Run|Run item from the PowerJ
menu. The applet ran just fine, so we continued the process of developing
our applet. We brought up PowerJ´s JToggleButton property sheet
and used it to place the word "Stop!" inside the toggle button below
Duke´s picture. When we were done, our design form was almost a
carbon copy of the window used in our original Swinging Duke program.
Adding an event handler
When we finished the GUI interface for our Swinging Duke
applet and tested it to make sure it still worked properly, we were
ready to write an event loop to stop and start Duke´s swinging action
and to switch the text shown in the toggle button beneath Duke from
"Stop!" to "Swing!" and back again.
When we started the job of adding an event handler to our applet,
we experimented briefly with using PowerJ´s reference page to help
us generate our event-handling code automatically. But we wound
up concluding that the code sequence needed for the task at hand
was a little too complex to create interactively. So we finally
decided to write our event handler from scratch -- an option that
can be a trifle messy with some IDEs but proved not to be a problem
at all with PowerJ.
To create an event handler, we right-clicked the JToggleButton
under Duke´s picture. A hierarchical menu then popped up, and we
selected an actionPerformed
event, as shown in the following screen shot:
When we had made that choice, PowerJ opened a code editor, generated
an actionPerformed()
method, and placed the editor´s insertion point at the appropriate
location for an event handler in our applet´s source file. Then
all we had to do was write an event handler at the indicated location.
Actually, the process was even simpler than that, because we quickly
realized that an event handler much like the one we needed was already
available -- we had already written one for our original hand-crafted
non-IDE Swinging Duke program. That original program´s event handler
was so similar to the one we were look for that it simplified our
next task significantly. All we had to do was clip some code out
of our original Swing Duke program, paste it into our PowerJ applet,
and edit it a little. Its overall framework remained the same.
When we were done, we had an event handler that looked like this:
public void btnToggle_actionPerformed(
java.awt.event.ActionEvent
event )
{
if (btnToggle.isSelected()) {
btnToggle.setSelected(true);
btnToggle.setText("Swing!");
try {
boxImage.setImage(
new java.net.URL(
"file:///c:/Applets/images/Swing-64_still.gif" ) );
} catch (java.net.MalformedURLException
e) {
System.out.println("Badly specified URL");
}
} else {
btnToggle.setSelected(false);
btnToggle.setText("Stop!");
try {
boxImage.setImage(
new java.net.URL
("file:///c:/Applets/images/swing-64.gif" ) );
} catch (java.net.MalformedURLException
e) {
System.out.println("Badly specified URL");
}
}
}
The results
When
we completed our event handler, we tested and debugged it, and then
executed our completed applet by choosing the Run|Run menu
item. Again, our applet worked like a charm. It presented a screen
display like the one shown on the right,
and it operated just like our original non-IDE program.
Playing with the project
In case you have a PowerJ system of your very own and would
like to experiment with the project we created in this article,
we´ve created a zip file that contains all the files in our Swinging
Duke project. To retrieve it, just click the Download button:
Conclusions and speculations
Our hands-on test
firmly convinced us PowerJ is an outstanding IDE. Once you learn
how to use it, PowerJ greatly simplifies the task of writing a user
interface -- and it doesn´t impose the kinds of code-writing restrictions
that so often infuriate power programmers who are trying to make
their lives a little easier by using IDEs.
We were also impressed by PowerJ´s support for Swing, and
we´re told that the next release of PowerJ will offer even more
Swing-related enhancements. We can´t say exactly what they are yet,
but watch this space for more details.
Although we didn´t try out all the enterprise-related software
that comes with PowerJ, we´re also anxious to perform that kind
of test -- and to report on its results in an upcoming issue of
The Swing Connection. Since PowerJ is manufactured by Sybase --
one of the top companies in the field of relational databases --
it will be interesting to see how PowerJ performs as part of an
enterprise system that interfaces Swing components with a relational
database system.
|