Sun Java Solaris Communities My SDN Account Join SDN
 
New to Java Programming Center

New to Java

Programming Center

Java Platform Overview | Getting Started | Step-by-Step Programming
Learning Paths | References & Resources | Certification | Supplements




Download or Print -->

Application Objects

The Java programming language has a lot in common with everyday life. Each day you use objects, such as the car you drive, the meals you eat, and Internet pages you read.

Left bracket  
Setting up the Java 2 Platform

Java 2 Platform, Standard Edition version 1.3.1

Setting Up and Getting Started

Lesson: Solving Common Compiler and Interpreter Problems
  Right bracket

Java applications are also built of objects, such as buttons, scroll bars, menus, and text areas.

In addition, objects do something. Your car gets you from one place to another. To do that, it has to have function, or many functions. Software objects also have function.

For action to take place in Java objects, blocks of code called methods are used. Methods tell an application what to do when buttons are clicked, menus are opened, and text is typed. Methods are either predefined or are created from scratch to manipulate objects, or the data within those objects.

The Dive Log application you're going to create consists of many objects. These objects are based on classes that detail how the object is defined and how it behaves.

This lesson covers the basics of using predefined classes and creating, or designing, new objects with your own classes. In addition, you'll learn how to work with objects by calling predefined methods and writing new methods to get the application to do what you want it to do.

Preparation

Before learning about the code for the Dive Log, you need to create a special directory for the files and images that build this application.

The Dive Log is designed from many classes, therefore many files. Keep them organized and in place.

Follow these steps
  1. Create a directory called divelog.
  2. Under the divelog directory, create another directory called images.

  3. For the Windows platform:
    C:\divelog\images
    


    For the Solaris environment:
    %home/usr/divelog/images
    

Dive Log Objects

The concept of software objects is easier to understand with a real world example. Everything you're going to create for the Dive Log application is an object, including the application itself. The Dive Log application main screen lists some of the visible objects.


Visible objects in the completed Dive Log

Each object has its own characteristics, or state. The Title object is different from the Tab objects, and the Image objects are different from the Text Area objects. But before an object comes into existence, its design must be written.

Before cars and houses are built, someone designs a blueprint. Before a batch of cookies is baked, a recipe is written. Software objects are also created with a specific design.

The design for a software object is called a class. Classes detail, or specify, exactly how an object should appear and how it is to behave. Instructions for creating software objects are carefully written into the class using variables for data and information, and methods for manipulation of that data and information.

Do you think there is a limit to how many objects make up an application?
   Yes             No