JBuilder for Dummies


Even without the sophisticated development tools that C++ and Visual Basic enjoy, the Java programming language has attracted the interest of countless computing professionals. Now, with Borland's JBuilder -- and JBuilder For Dummies -- you can easily transform your interest in the language into real, practical Java applets and applications.

In JBuilder For Dummies, Java expert Barry A. Burd provides the information you need, whether you're new to Java or just new to JBuilder. ...

See more details below
Available through our Marketplace sellers.
Other sellers (Paperback)
  • All (7) from $1.99   
  • New (3) from $58.77   
  • Used (4) from $1.99   
Sort by
Page 1 of 1
Showing All
Note: Marketplace items are not eligible for any BN.com coupons and promotions
Seller since 2008

Feedback rating:



New — never opened or used in original packaging.

Like New — packaging may have been opened. A "Like New" item is suitable to give as a gift.

Very Good — may have minor signs of wear on packaging but item works perfectly and has no damage.

Good — item is in good condition but packaging may have signs of shelf wear/aging or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Acceptable — item is in working order but may show signs of wear such as scratches or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Used — An item that has been opened and may show signs of wear. All specific defects should be noted in the Comments section associated with each item.

Refurbished — A used item that has been renewed or updated and verified to be in proper working condition. Not necessarily completed by the original manufacturer.


Ships from: Chicago, IL

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
Seller since 2015

Feedback rating:


Condition: New
Brand New Item.

Ships from: Chatham, NJ

Usually ships in 1-2 business days

  • Canadian
  • International
  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
Seller since 2015

Feedback rating:


Condition: New
Brand new.

Ships from: acton, MA

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
Page 1 of 1
Showing All
Sort by
Sending request ...


Even without the sophisticated development tools that C++ and Visual Basic enjoy, the Java programming language has attracted the interest of countless computing professionals. Now, with Borland's JBuilder -- and JBuilder For Dummies -- you can easily transform your interest in the language into real, practical Java applets and applications.

In JBuilder For Dummies, Java expert Barry A. Burd provides the information you need, whether you're new to Java or just new to JBuilder. Burd orients you to the JBuilder user interface and covers in plain English such essential topics as

  • Defining object-oriented programming
  • Taking advantage of the JBuilder program's built-in Project, Applet, and Application Wizards to streamline your programming
  • Discovering what the JBuilder program's innovative AppBrowser has to offer (after you've programmed with it, you'll never be able to go back to your old way of programming)
  • Avoiding reinventing the wheel by using Java's Abstract Windowing Toolkit (AWT)
  • Putting together a complete Java-based Web application
  • Enhancing your applets' interactivity, including adding sound and animation

Plus, JBuilder For Dummies comes complete with a bonus CD-ROM containing the author's own sample applets and code, as well as Windows software, such as

  • JBuilder Professional Publisher's Edition -- a 90-day trial version of JBuilder
  • JBuilder Presentation -- a detailed multimedia demonstration of the JBuilder program's feature set
  • Paint Shop Pro -- the amazing shareware image-editing program for PCs
  • Astound WebMotion -- a trial version of the easy-to-use program for adding animation toyour Web pages
  • Home Site 2.0 -- the popular HTML editor from Bradbury Software
Read More Show Less

Product Details

  • ISBN-13: 9780764500787
  • Publisher: Wiley, John & Sons, Incorporated
  • Publication date: 11/28/1997
  • Series: For Dummies Series
  • Edition description: BK&CD ROM
  • Edition number: 1
  • Pages: 384
  • Product dimensions: 7.39 (w) x 9.20 (h) x 1.00 (d)

Table of Contents

Is This the Right Book for You?
How This Book Is Organized
Part I: Starting at the Beginning
Part II: Expanding from the Basics
Part III: Expanding Your Horizons
Part IV: The Part of Tens
What to Read and What to Skip
Icons Used in This Book
The Accompanying CD-ROM
Words of Encouragement and Inspiration
Part I: Starting at the Beginning
Chapter 1: JBuilder's Object-Oriented World
What Is Object-Oriented Programming?
What about Java?
Built-in security features
Marketable skill
The Internet Comes along and Changes Everything
Rich and Tasty: JavaBeans
Enter JBuilder

Chapter 2: Starting JBuilder

You Gotta Have a Project
Parts of the JBuilder Screen
The Main window
UI Designer and the Inspector
Assorted other goodies
A Typical JBuilder Work Session
Parts of the JBuilder AppBrowser
The Navigation pane
The Content pane
The Structure pane
Different Modes for Different Codes
Viewers and Editors in the Content Pane

Chapter 3: Why All the Fuss about Object-Oriented Programming?

Programmers Stop Reinventing the Wheel
What Is an Object? What Is a Class?
Properties and Events
The Application Programming Interface

Chapter 4: The Wizard of OOP

Files, Files, Files
Make Something New
The Project Wizard
The Applet Wizard
Talking to the Applet Wizard: Some Suggestions
Step 1: The Applet Class/Applet Style step
Step 2: The Applet Parameters step
Step 3: The HTML step
The Application Wizard
Step 1: The Application Class/Application Style step
Step 2: The Frame Class/Frame Style step

Chapter 5: AppBrowser, All Things to All Users

Calisthenics for Your AppBrowser
Panes too small?
Tabs too small?
AppBrowser too small?
The AppBrowser's Panes
The Navigation pane
The Structure pane
The Content pane
The Project mode
The Opened Files mode
The Directory mode
The Hierarchy mode
The Search mode
Delve Deeper with the Structure Pane
Structures galore
Move around with ease using the Structure pane
Drilling down
Navigation buttons
The Content Pane -- What You Get Is What You'll See
Finding and replacing
Incremental Search
Search Source Path
Record and playback keystrokes
Do it the old-fashioned way
Part II: Expanding from the Basics

Chapter 6: UI, UI, Oh-ho, We Gotta Go...

The Component Palette
Components from Java's Abstract Windowing Toolkit
Borland's control components
From the Component Palette to the UI Designer
Setting Properties
Changing a value directly in the UI Designer
Changing a value using the Inspector
Using a dialog box to change a value
The Inspector can present alternatives
What's in a name?

Chapter 7: A Brief Interlude: Our Plan to Get Money from Clients

An Online Form

Chapter 8: Don't Just Sit There...

Adding Actions to Your Applet or Application
The Interaction Wizard
Step 1
Step 2
Step 3
Step 4
Make Your Button Cry "Uncle"
The Interaction Wizard Editor
Step 1
Step 2
Step 3
Bruising a Button
Labels Have Feelings, Too
UI Components and Non-UI Components
Infonit Comes along and Spoils All the Fun
Create the components that you're going to need
Group the check boxes
Use the Interaction Wizard
Display a Message
Grab your components
Expose that message for the actor that it really is

Chapter 9: Java One-liners

Java One-liners: An Executive Summary
The big picture
So Many Components; So Many Methods to Choose Among
Puzzle Pieces
So where do I find a String?
How to paste two Strings together
Warning: Overload Imminent
Method overloading
Some Methods Take More Than One Parameter
How to Add a Line of Java to Your Program
On behalf of Infonit, I thank you

Chapter 10: Useful AWT Components and Their Methods

Get the text; set the text
Find out what's selected
Show your TextComponent who's the boss
Now show the user who's the boss
Get the number of columns and the number of rows
Change the area's text
Get the text; set the text
Change the label's political orientation

Chapter 11: I Have to Say, It's Getting Better

A Modest Goal
Create a new applet
Make the most of the HTML code
Add components for the visitor's first name
Add components for the visitor's interests
Add a button (visitors enjoy clicking buttons)
Add blank labels
Make the button do something
Finally, revel in the beauty of your work
Line Up Those Components
Lay the groundwork
Select two components at the same time
The Alignment pop-up menu
Step-by-step resizing and aligning
Not Fond of Labels? Try a Text Area
Give Your Visitor Some Help
Create a label
Add an event handler
The hard way; the easy way
Take a Byte Out of Time
How to create your program

Chapter 12: A Bit Iffy or an Iffy Bit?

Do This...or Do That
if Statements
if (eighteenBox.getState( ))
Example: An Image Appears
Using Braces to Group Parts of an if Statement
Boolean Operators
A list of comparison operators
Strings are different
Part III: Expanding Your Horizons
Chapter 13: Another Cup of Java
Save Yourself Some Work
The hard way
The easy way
Use the same technique again
Assignment Statements
Convert before you assign
Types in Java
The simple things in life
Making up your own variable names
Creating and Using Variables: A Short Summary
Example: A Fund-Raising Scorecard
Create the user interface and the code
The lifetime of a variable

Chapter 14: More Components

Checkbox and CheckboxGroup
Get a label; set a label
Is the box checked?
Check your local radio station
The CheckboxGroup methods
Pinpointing a scrollbar's values
How much does the value change?
Adding and selecting items
Taking inventory of your items
Making a list, letting the user check it twice
Properties and methods
Adding items
Selected items in a ListControl component

Chapter 15: Picture This

Windows and Frames
A frame's simple methods
A frame's not-so-simple methods
Getting an image file
Java's try statement
A quick example
Edge and fill
What kind of shape is it?
The ShapeControl's methods

Chapter 16: Dreams Realized

Plan, Plan, Plan
Start a JBuilder Project
Point and Click
The Infonit Logo
Sizing the image
A slider instead of a scrollbar
What's Your Title?
Who Are You?
Where Do You Live?
And What Would You Like to Buy from Us?
Do It!
A Place for Your Sales Pitch
Adding Code
Slide the Slider
Thanks for nothing
Dear visitor...
...We offer the services you need...
...And we'd like you to call us
Using a ListControl Component

Chapter 17: Creating Menus

Menus -- Some Terminology
Creating Menus
Adding a menu
Adding a menu item
Adding a submenu
This is a separator
A giant step backwards
A Familiar Example
Set up the menus and the items
Add some text areas
Adding code
The About Box
Filling in your own text
Adding your own image
Pop-up Menus
Create the menu, the submenus, and the items
Add actions
Make the menu pop up
Don't Right-Click -- Double-Click

Chapter 18: Layouts

Layouts, Containers, and Components
Flow layout
Border layout
Grid layout
Card layout
Everybody duck! Here comes the GridBag layout!
XY layout
Layouts within layouts within layouts
Creating Layouts in the UI Designer
The XY layout and the Flow layout
The properties of a layout
Back to an XYLayout
The border layout
The grid layout
The card layout
The card layout's methods
Ode on a GridBag layout
The GridBag experiment
Setting the GridBag's Grid Positions

Chapter 19: ... And More Layouts

Planning Your Layouts
The Infonit Company's Web Page
The top third
The middle third
The bottom third
The JBuilder Layout ARQ File
The XY layout versus the standard Java layouts
Things inside other things
FAQ or Fiction?

Chapter 20: Deploying Your Program
What are the issues?
Prepare Your Code
Relative path names
Add files to the project
One more build; one more run
Put Your Files in a JAR
Select files to deploy
Deploy options
Deploy as...
Archive output path
Do it
Your Code's Final Destination
Deploying an applet
Deploying a stand-alone application
Part IV: The Part of Tens
Chapter 21: Ten Debugging Steps
Go to JBuilder's Online Help Screens
Mind Your Grammar
Compare for Consistent Capitalization
Add Some New Output
Comment Suspicious Code Out
Experiment with Changes
Run the Debugger
Find out Why the Computer Is Doing What You Told It to Do
Compare It with Code That Works
Show It to a Friend
When All Else Fails, Find a Workaround

Chapter 22: Ten Interface Design Keys

Be Consistent
Use Informative Labels and Abbreviations
Use Standard Styles
Make Clear What's Required and What's Optional
Provide Defaults
Create Simple Paths from One Element to Another
Forgive Mistakes
Design for Varying Levels of User Experience
Avoid Excessive Coolness
Learn from a Kindergartner

Chapter 23: Ten Neato Web Page Tips

Use Netscape's Color Palette
Put Things on Angles
Use Images and Text
Chop up Your Content (But Don't Pulverize It)
Steal Ideas, but Do It Honestly
Do a Thorough Alpha Test
Do a Beta Test
Test Your Work on Several Browsers
Include Useful Materials
Ask Yourself If You'd Want to Visit Your Site
Part V: Appendix
Appendix A: About the CD-ROM

License Agreement

Installation Instructions

Book Registration Information

Read More Show Less

First Chapter

Chapter 3
Why All the Fuss about Object-Oriented Programming?

In This Chapter

  • Classes, properties, and other pillars of object-oriented Programming
  • Waiting for an event to happen
  • Cashing in on your inheritance
  • Java's built-in programming goodies

Foolish as I am, I decided to write a useful list of Java programming principles, all in one chapter. Years from now, reviewers will be saying

The most ambitious effort to describe a complicated subject in as few words as possible can be found in JBuilder For Dummies, published way back in A.D. 1997.

Editor's note: Some of Burd's vast oversimplifications proved useful to programmers of the day.

Well, here goes.

JBuilder is designed to help you avoid writing Java code. And why should you avoid writing Java code? It's not because you're lazy. It's because dragging and dropping with JBuilder is a better way to create applications. It's better than typing your Java code for two reasons.

  • It's quicker.
  • It's less error prone.

As a JBuilder user, you can create better applications much faster than a programmer who types Java statements into the Windows Notepad editor. But, one way or another, your application is still written in Java. Here's what a very small Java program may look like.

import java.applet.Applet; 
import java.awt.Graphics;

public class HelloWorldApplet extends Applet {
public void paint(Graphics g) {
g.drawString ("Hello Brave New World!", 50, 25);

Never mind what this code means. The point is that, underlying all the dragging and clicking you do in JBuilder, Borland's product is constantly creating text files containing Java source code. When you build and run your new JBuilder-made application, the computer is working from the Java code, not from the original mouse movements that JBuilder had you use in order to create the application.

This chapter describes some of the ideas that make Java the big deal that it is. You won't learn to write Java code by reading the chapter. Instead you get a clear understanding of JBuilder's "big picture." This big picture is important because, if you don't have it, you can easily get lost in the forest of clicks and keystrokes.

Programmers Stop Reinventing the Wheel

We all know what it's like to redo work that someone else has done. It's frustrating. What's more, it's not economical. Well, imagine a world in which thousands of computer programmers are all starting from scratch, and doing it every single day of the week. In one small company, at least ten programmers are all working on the same problem, and none of them makes use of the work of others.

Imagine this world in which programmers routinely throw their own programs out the window and start working on the same problem all over again. A programmer writes code to print the date 2/13/1975, and then some crazy supervisor declares that 1975 wastes disk space. "It should be 2/13/75," says the supervisor. Rather than untangle the knots created in the original four-digit year program, our poor programmer starts all over again with a pencil and a blank piece of paper.

Well, this was the world of 1975. Very few people knew how to reuse good code. For a while it looked as if computing would never move forward. The bigger the goals became, the more work it took to start with nothing and build up a whole new set of computer programs.

Then along came Object-oriented Programming, otherwise known as OOP. Central to OOP is the notion of inheritance. Stated simply, inheritance means acquiring the benefits of the work done in earlier programming efforts.

Before OOP, programmers talked in terms of instructions. An instruction is an imperative statement, like an order or a command. "Do this, then do that." The programmer instructs the computer to do something.

Object-oriented Programming worries less about instructions and more about things called objects. In real life, you won't inherit much unless you have a rich Uncle Ebenezer. In OOP, you can't inherit any goodies unless you have a "thing" to inherit them from. So Object-oriented Programming deals first and foremost with things. In OOP, the instructions come almost as an afterthought.

What Is an Object? What Is a Class?

Object-oriented Programming deals with "things." In the Java language, you can't do much without first defining the things you're doing it to. A Java "thing" is normally called an object. An object is a big collection of stuff, consisting of variables (places to store values) and methods (lists of statements describing what you do with the object).

For instance, a pyramid-shaped object may have several variables -- height, width, distance from the left edge, distance from the top, rotation, and so on. The pyramid object may also have several methods -- things you do with a pyramid, such as make a new pyramid, get a pyramid's location, change its size, and rotate it.

The methods for doing things with objects belong to the objects themselves. For instance, a pyramid owns its own "change my size" method. To change a pyramid's size, a program may execute a statement like


which tells the pyramid to run the statements in its own setSize( ) method.

Every method has to have a name, such as the names setSize( ) or computeFederalTax( ) or cookDinner( ). After all, a method gets called into action at various times during the run of your Java program. So various lines in the Java source code use this name as a sort of command to get the method running. A method, then, is a group of many statements collected together under a single name. If we cheat a little bit and substitute informal English for formal Java statements, then the following lines may be collected together to form a method named computeFederalTax( ):

Compute total income. 
Compute total deductions.
Subtract deductions from income giving taxable income.
Give up and hire an accountant.

Whenever you see a name followed by empty parentheses ( ) you can be pretty darn sure that it's the name of a method. That's how all the real Java programmers write about methods. Nothing fingers a novice faster than a method name without parentheses. Beware of anyone who writes, "Yesterday, I learned to use the setSize method."

A Java class is a template for making objects. You can't have an object without first having a class. In the pyramid example, first you define a Pyramid class (with variables to store values and methods to twiddle with pyramids). Then use your Pyramid class as a template to form a bunch of pyramid objects. Each pyramid object may be a separate pyramid shape that's displayed on the screen. The business of creating objects from classes is called instantiation. Every object is an instance of a particular class. For all you visual thinkers out there, this concept is illustrated in Figure 3-1.

A Java program is composed of classes, objects, variables, and methods.

  • A class is a template for making objects.
  • An object is an instance of a class.
  • A variable is a place to store a value or an object.
  • A method is a list of statements telling the computer what you do with a value or an object.

Properties and Events

Hold onto the notions of variable and method as you read about their first cousins, the concepts of a property and an event.

A variable is a place to store values. Ordinarily, a variable has a name. For instance, the name columns may stand for a variable that stores a number of letters you can display in a text field. Somewhere inside the computer, there may be a few bytes of memory with a number of columns stored in binary code. In the Java program created automatically by JBuilder, you may find a line that looks something like this

int columns;

This tells the computer to reserve a memory location for the variable named columns and to interpret the 32 bits in that location as a whole number (a number with no fractional part).

JBuilder spares you the tedium of having to examine all the Java code. Instead, the meaning behind the code is described visually -- in pictures or in tables. The Inspector is a table of sorts. The Inspector describes the properties of a text field. The row labeled columns defines the number of letters that can be displayed in the text field. If the text field contains more than 20 characters, some of them will run off the edge of the field. Figure 3-2 illustrates the Inspector.

In Figure 3-2, the Inspector describes the textField1 object. Each of the Inspector's rows describes a property of the textField1 object. Look at the row labeled columns and notice that the value of the columns property is 20. The text field is wide enough to display 20 letters. Any extra letters will run off the edge of the field.

But what's this property business? Didn't I just finish referring to columns as the name of a variable? Well, it's both. As a name used inside the Java source code, columns is a variable. But the way this name is used in the code (we won't go into that right now), columns ends up being a property of a text field object.

A variable can be a property, and a property can be a variable. In this book, the difference hardly ever matters. A variable has a value. ("The value of the columns variable is 20.") A property has a value. ("The value of the text field's columns property is 20.") In each case, a text field is 20 characters wide. The word "variable" suggests a name that's used in a Java program. And after you use the name in a program, the word "property" suggests the resulting characteristic of an object.

Experienced Java programmers understand that the distinction between a variable and property is more subtle than what I just described. Well, let them have their fun.

Now take another look at the Inspector and notice how it has two little tabs at the bottom. One says Properties; the other says Events. An event is something that can happen to an object. A button object can be clicked; a check-box object can be checked; a text field object can get typed into it.

Some events are more subtle. Have you filled out an online form and noticed the cursor jumping from one text field to another when you press the Tab key? After it has acquired the cursor, anything you type on the keyboard gets echoed in this new text field. Technically, we say that this new text field has the focus. It's a fancy way of saying that this particular field receives the user's keystrokes. Well, getting the focus is an event. So in this example, an event "happens" to a text field without anyone's actually clicking on it or typing in it. Not all events are alike.

Programs that run in windowed environments are generally called event-driven programs. This emphasizes the fact that much of the action happens in response to events initiated by the user. The user clicks a button, and the program rolls into action.

An alternative to event-driven programming is the older style in which the program asks the user for input, pauses, gets a reply, does something with it, and then asks for more input. Generally, the user doesn't do anything with a mouse. (The chain of actions occurs on one line after another on a simple text screen.) If you work extensively with MS-DOS programs, you're familiar with this kind of program.

The real work of your applet or application is responding to events. That's why JBuilder's Inspector has a table of events. By using the Inspector, you can create (or change, or examine) your program's response to an event.

And now it's time to make the connection between events and methods. Remember what a method is? It's a list of statements telling the computer what you do with an object. This list is given a name, so that the command to execute the entire set of statements can be given in just one bold stroke.

Well, if you issue this command in response to an event, your method is called an event handler. That's all there is to it.

Take a look at Figure 3-3. The Events page of the Inspector has two columns -- one for the kinds of events that can happen to an object, another for the names of the corresponding event-handling methods.

  • The kinds of events include things like keyPressed and mouseClicked.
  • The column with the names of event handlers starts as a blank.

    The event-handling methods are created only at your request. In one of these blank spaces, perform the following ritual: Click, then click again, and finally double-click. JBuilder will make up a name for a new event-handling method. For a button that's already named submitButton, the new event handler may be named submitButton_mouseClicked( ).

After an event-handler name is created, JBuilder adds the method to your automatically generated Java source code.

void submitButton_mouseClicked(MouseEvent e) { 


The method includes a big blank line where you can type your own Java statements -- things that should happen when the submitButton is clicked.


Here's an example of a method written in the Java programming language.

public void paint(Graphics g) { 
g.setFont(new Font("TimesRoman", Font.BOLD, 24));
g.setColor (Color.blue);
g.drawString ("Hello Brave New World!", 50, 25);

JBuilder can write all this stuff for you as long as you fill in some dialog box fields and tell it what kind of font you want, what colors you'd like, and so on. The only time you need to look at this Java source code is

  • When you want to tweak something in your application and JBuilder's tools aren't dexterous enough to do it
  • When something goes seriously wrong in your application and the only way to figure out what's wrong is to stare at the Java code
  • When the AppBrowser's Content pane is open to its default view -- the Source view -- and you can't help but see all the Java code inside

JBuilder shields you from a lot of Java source code. Even so, it helps to have an inkling of how the source code works. Here's a list of things to remember about Java methods.

  • A method is a list of statements.

    The paint( ) method on the previous page has three statements -- one to set the Font, another to set the Color, a third to actually draw a String of characters using that Font and that Color.

  • A typical method describes only a portion of the action in your entire program.

    One way of thinking about a method is to imagine that it's a specialist in performing some small subtask that's part of your overall application.

  • A method has a name.

    The name of the method at the start of this section is paint( ).

  • A method has a declaration.

    The code at the start of this section is the declaration of a method called paint( ). It's the list of statements to be executed whenever the method is called into action.

  • A method can be called into action.

    Chances are, the declaration is in one part of your program, and a statement that calls it is in another part of the program, nowhere near the declaration. The statement that calls a method into action is a method call, just a call. A call to our paint( ) method may look like this

  • Roughly translated (and I do mean "roughly") this means "Your Applet has its own paint( ) method; so run that method."

    The Java language is case-sensitive. This means you cannot use YourApplet, yourapplet and yourApplet interchangeably. These three spellings wouldn't have the same meaning. A method called paint( ) can't be referred to as Paint( ). Changing the capitalization simply won't work.

    Think about the definition of a word in a dictionary. The definition has no effect at all until someone actually uses the word. A method's declaration works the same way. It doesn't do anything until some other part of the program executes a method call.

  • Each method belongs to a particular object.

    The Java statement in the last bullet says "Your Applet has its own paint( ) method...." If you saw all the Java code that normally surrounds the declaration of our paint( ) method, you'd see that the declaration is probably part of an applet. And the run of an applet is an object, like any other. So every time you run an applet, the computer creates a paint( ) method for that new applet object. (Imagine millions of paint( ) methods all over the world at this very moment!)

    There's one exception to this method/object rule, but as a JBuilder user, the exception won't concern you very much. Java has a kind of method called a static method. A static method doesn't belong to a single object; it belongs to a whole class of objects.

  • A method can hand a value back to the code that called it into action.

    You've created an applet. There's a button labeled Roll sitting in the middle of it. The name of this button object is rollButton. When a visitor clicks the button, a pair of dice appear to start rolling, and the button's label changes to the word Stop. Here's some Java code that helps you figure out which word is currently on the button's label.


    Like every other button object, the rollButton has a getLabel( ) method. The declaration of getLabel( ) is buried somewhere in Java's Core API. (See this chapter's section "The Application Programming Interface".) What we see here, rollButton.getLabel( ), is actually a call to get the method running.

    But here's the kicker. The call rollButton.getLabel( ) stands for a value. The value is either the word Roll or the word Stop, depending on which label is currently on the face of the button. A Java statement to display the button's current label may look like this


    In this statement the word Roll or Stop is handed to System.out.println( ), which is another method in Java's Core API. The System.out.println( ) method takes the word that's handed to it and sends it to be displayed somewhere (normally on the MS-DOS screen).

    Okay. So what? A word like Roll or Stop is called the return value of the call to the getLabel( ) method. Some methods return a value; others don't. The getLabel( ) method always returns a value. In contrast, the System.out.println( ) method never returns a value. It just does its displaying and then goes away. There's another button method, called setLabel( ), that doesn't return a value.


    The setLabel( ) method just changes the word on the face of the button. It doesn't return a value of any kind, so it wouldn't make sense in a Java program to write

        //This code is INCORRECT: 

    And how do you figure out which methods return values? In JBuilder's Main window you select Help-->Java Reference. As you look through the documentation, you find methods with the word void in the first lines of their declarations.

         public void println(String x)

    These are the methods that don't return values. The others do.


How does an applet get to be an applet? Well, how does a rich person get to be rich? Basically, there are two ways:

  • Inherit it from your relatives
  • Get it on your own

Most people (and applets) do a combination of these things. First, they get a bunch of nice things from their parents; then they create some important assets with their own talents.

We know what kinds of assets the rich people have, but what about the applets of this world? Well, it boils down to the same old things -- properties and methods. To review

  • A property is a variable that stores a certain characteristic of an object. For instance, the word that appears on the face of a button is stored as a property called label.
  • A method is a list of statements describing something you can do with the object.

Now here's a very small Java applet. All it does is display the words Hello Brave New World somewhere on the screen. You can create this code with JBuilder (...but, to get code that's this simple, you'd have to dig into the Content pane and delete many of the unnecessary statements that JBuilder creates automatically).

package HelloApplet; 
import java.applet.Applet;
import java.awt.Graphics;

public class... HelloWorldApplet extends Applet {
public void paint(Graphics g) {
g.drawString ("Hello Brave New World!", 50, 25);

The public class line announces that we're describing a class called HelloWorldApplet, and that HelloWorldApplet starts off being very much like a pre-written class that comes with Java -- the class called Applet. In fact, the word extends tells the system to make HelloWorldApplet be identical to Applet until further notice (and, in fact, that "further notice" comes in the next few lines of code). This is like a parent-child relationship between classes. It's one of the keystones of Object-oriented Programming. It comes with all kinds of formal terminology.

  • HelloWorldApplet is a subclass of the Applet class; Applet is the superclass of the HelloWorldApplet class.
  • HelloWorldApplet is a child of the Applet class; Applet is the parent of the HelloWorldApplet class.
  • A HelloWorldApplet is an Applet, but a HelloWorldApplet has an extra paint( ) method of its own.
  • The HelloWorldApplet class inherits certain properties and methods from the declaration of the Applet class. Inside the declaration of the HelloWorldApplet class, the paint( ) method is redeclared in a way that's appropriate to HelloWorldApplet. Using the correct Java lingo, we say that HelloWorldApplet overrides the Applet's existing paint( ) method.

So what handy things does our HelloWorldApplet class inherit from the Applet parent class? Well, it inherits methods to get itself started running, to stop running when that's needed, to get information from a Web page in the Internet browser, to show a message on the browser's status line, to display an image, to play a sound clip, and lots more. Our HelloWorldApplet uses only a small fraction of these things.

There's one big difference between inheriting from a class and inheriting from a rich relative. When you inherit money from Aunt Bertha, it's money that she never spent. On the other hand, when you inherit from the Applet class, you're making use of code that has been used to make thousands of other Java programs. This is a great example of code reuse in Object-oriented Programs.

The Application Programming Interface

The last section talks about inheriting properties and methods from older Java programs. That's fine as long as you've got some older Java programs just lying around. But what if you don't have these things? Where can you find a rich Uncle Ebenezer with a frail constitution and a mattress full of Java code?

The answer is Java's Core API -- the Application Programming Interface. The API is a huge collection of useful methods and other things, all written in the Java programming language. Java has several such collections. The most widely used is the Java Core API. The methods in the API are useful in most general-purpose computing environments. The API is available to you when you use Java in any form.

Each method in the API has a name, and the names follow several different patterns. For instance, as part of the JavaBeans standard, each component has two methods called getLocation( ) and setLocation( ). A method whose name starts with get or set is called an accessor method because it provides access to one of an object's properties. This uniform naming pattern for accessor methods helps JBuilder to create Java code without having to stop and look up method names in a big table somewhere.

To learn more about Java's API, you have two options, and you should take advantage of both of them.

  • Read Chapters 10, 14, and 15 in this book.
  • Select Help-->Java Reference from JBuilder's Main window. After you reach the reference material on Java's API, stay there and sniff around for a while.
Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)