Spinner Suite Of Beans

TOC

Overview

Purpose

The spinner suite of beans is a component with two small direction buttons that lets the user modify the value in an input field or possibly enter a new legal value directly in the input field.

The Spinner suite of beans consists of three beans according to their data types: the DigitalSpinner Bean, DateSpinner Bean and the TimeSpinner Bean 


previous Audience

This document is intended to be used by application builders who would like to build Java applications using the three kinds of spinners. The application developer is expected to be familiar with the Java language and the JavaBeans architecture. The developer should be familiar with building applications by linking beans in an application builder tool. Familiarity with the functionality of Spinner would be advantageous, though not mandatory if the developer does not intend to extend the functionality provided by the beans.


previous How to Use This Guide

Guide Conventions

Typographical Conventions

Conventions Description Example
Text in italics names of dialog boxes, figures, reference to chapters and other sections, task name etc. Figure 1, Overview, etc.
  • Round bullets
list of points
  • DigitalSpinner Bean
  • DateSpinnerl Bean
  • TimeSpinner Bean
Numbered list 1, 2, 3, .... sequential steps
  1. Set the minimum and maximum value.
  2. Set the current value.
Text in Bold and Italics name of the file Spinner.zip, readme.html
Text in Courier font names of classes, methods, events, part of code included in the document, etc. ActionPerformed

Images

Image Used to
previous navigate to the previous sub-heading
up navigate to the previous main heading
toc return to the Table of Contents
note represent a Note information

Guide Organization

Overview - introduces the user to the Spinner suite of beans. Provides information like intended audience, guide organization and copyrights

Component Description - describes the Spinner component in general. It gives list of beans in the suite and deployment scenarios

Installation Instructions - describes the hardware and software required for installing and using the Spinner suite of beans, and also describes how to install the beans and prepare them for use.

Usage Instructions - provides information on bean usage, wiring scenarios and serialization.

Alternating Wiring Scenarios - describes special wiring scenarios that may involve beans within and outside the component suite.

Individual Bean Documentation - provides links to individual bean documentation which describe each bean in the suite w.r.t. its events, properties methods etc.

User Interface - describes the various user interface components of the SMTP component..

Demo Application - describes the demo application and provides instructions on how to run the demo application.

References - provides links internet sites which give substantial reference documentation.

Glossary - gives a brief explanation of some of the technical terms used in the document.


previous Copyrights And Trademarks

Copyright © 1998 IBM Corp.

All rights reserved.

IBM and VisualAge are trademarks of International Business Machines in the United States and/or other countries.

* Java and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc, in the U.S. and other countries.


Up button

Component Description

previous General Description

The objective of the Spinner suite of beans is to provide diverse applications with the ability to modify the value in an input field or enter a legal value to the input field.

Based on the data types, the Spinner suite of beans internally consists of three beans :

These beans may be used together or separately.


previous List of Beans

The Spinner suite of beans consists of :


previous Deployment Scenarios

The Spinner suite of beans is to provide diverse applications with the ability to modify the value in an input field or enter a legal value to the input field. It consists of three types of spinners(DigitalSpinner,DateSpinner and TimeSpinner). Since they are standalone, there are no special deployment problems among them. 


Up button

Installation Instructions

Hardware Requirements

These JavaBeans are designed to be compliant with 100% Pure Java requirements, and will therefore execute on any hardware platform that supports the Java Environment.

43KB of disk space is required to install the Spinner Bean Jar files to VisualAge for Java and 52KB is required to install it to Visual Cafe. Additional hard disk space would be required to install the Java Development Kit, Bean Development Kit or any Java Application Builder Tool which may be used to build / compile applications using these beans.


previous Software Requirements

The Spinner Beans are designed to work with Java Development Kit Version 1.1 and above.

These beans may be linked to each other and tested in the BeanBox testing tool from JavaSoft.

Any Java Application Builder (E.g. VisualAge for Java from IBM Corp, VisualCafé from Symantec Corp., Java Workshop from SunSoft) with JavaBeans support may be used to develop applications using these beans.


previous Installation

  1. After downloading spinner.zip, unzip it. It will automatically create a new directory called spinner and extract files into it.
  2. To use the components in the BeanBox, copy (using the relevant copy command on the operating system) the jar files for the required component (available in the lib directory) to the BeanBox's jars directory.
  3. To use any component in any of the IDEs, import the corresponding .jar file.

  4. Note : Please refer to the User's Guide of your IDE on how to import a bean into the IDE.

  5. To run the demo application provided with this package, follow the steps given below .


previous Platform Dependencies

There are no platform specific issues for the Spinner suite of beans. Any operating system that supports Java canbe used.


Up button

Usage Instructions

Bean Usage

The jar files of the Spinner suite of beans should be added to the jars directory of the beanbox. The wiring scenarios are described below.


previous Wiring Scenario

Since the three beans are standalone, there is no special procedure involved in integrating all the beans in the suite.


previous Serialization

The beans in the Spinner suite are serializable


Up button

Alternate Wiring Scenarios

This section explains the special wiring scenarios that may involve beans within and outside the component suite.

  1. Scenario 1.1: Creates a DigitalSpinner, DateSpinner or TimeSpinner in the application builder.
  2. Scenario 1.2: Sets maximum value of DigitalSpinner.
  3. Scenario 1.3: Wires DigitalSpinner with a DateSpinner.


Up button

Individual Bean Documentation

DigitalSpinner Bean

DateSpinner Bean

TimeSpinner Bean


Up button

Reference to common properties

 


Up button

Reference to common methods

public void decrement()

Decrements the current value of the spinner.

public int getArrowStyle()

Gets the current arrow style of the spinner.

          Returns:
                  the current arrow style of the spinner.
 

public Color getBackground()

Gets the background color of the input area.

                 Returns:
                       the input area background color.
 

public Color getDownArrowColor()

Gets the down arrow color.

                 Returns:
                       the down arrow color.
 

public Font getFont()
 
Gets the current edit font of the spinner.

        Returns:
                  the current edit font of the spinner.
 

public Color getForeground()

Gets the foreground color.

                 Returns:
                       the input area foreground color.

public Color getUpArrowColor()
 
Gets the up arrow color.

               Returns:
                       the up arrow color.

public void increment()

Increments the spinner's current value.

          Returns:
                 null
 
public boolean isEditable()

Gets the spinner's current editable status.

          Returns:
                  the spinner current editable status.
 

public boolean isEnabled()

Gets the enabled status of the spinner.

          Returns:
                  the current enabled status of the spinner.
 

public void setArrowStyle(int style)

Sets the arrow style of the spinner.

                 Parameters:
                       style - the desired arrow style of the spinner.
 

public void setBackground(Color color)

Sets the background color of the input area.

                 Parameters:
                       color - the desired input area background color.
 

public void setDownArrowColor(Color arrow_color)

Sets the down arrow color.

                 Parameters:
                       arrow_color - the desired down arrow color.
 

public void setEditable(boolean edit_flag)

Sets the editable status of the spinner.

          Parameters:
                       edit_flag - the desired editable status of the spinner.
 

public void setEnabled|(boolean flag)

Sets the enabled status of the spinner.

                 Parameters:
                         flag - the desired enabled status of the spinner.
 

public void setFont|(Font edit_font)

Sets the edit font of the spinner.

                 Parameters:
                          edit_font - the desired edit font of the spinner.
 

public void setForeground(Color color)

Sets the foreground color.

                 Parameters:
                       color - the desired input area foreground color.
 

public void setUpArrowColor(Color arrow_color)
 
Sets the up arrow color.

               Parameters:
                       arrow_color - the desired up arrow color.
 


Up button

User Interface

This section describes the user interface of the Spinner beans.

Screens

The Spinner Suite of beans consists of three spinner beans, as shown in Figure 1.  Figure 1 - Main Screen

Following is the detailed explanation of the Spinner Main Screen components :

Input Area

The Input Area of each Spinner is used to input data directly by users.

Direction Buttons

The Direction Buttons is used for users to increase/decrease the current value with predefined increment / decrement value.


Up button

Demo Application

The demo directory contains all the necessary files for running the demo. This demo application demonstrates how the Spinner suite of beans can be used.
To run the demo application provided with this package, follow the steps given below :

  1. Make sure that the java executable is in the PATH and also the CLASSPATH variable points to the classes.zip in the JDK's lib directory.
  2. Set the CLASSPATH environment variable according to the instructions, given under the sub-heading Setting the CLASSPATH below.
  3. Enter the demo directory,type java SpinnerDemo in the command prompt. All the screens that come up in the demo application are explained in the section User Interface

Setting the CLASSPATH

WINDOWS CLASSPATH

After installing the software, update the CLASSPATH environment variable as follows :

  1. For WINDOWS NT :
  2. Start the Control Panel, select System, then edit the CLASSPATH environment variable.

    Set the CLASSPATH to point to
    spinner\lib\spinner.jar

  3. For WINDOWS 95 :
  4. To change the CLASSPATH, open the AUTOEXEC.BAT file and make the change to the CLASSPATH statement. (Be sure to make a backup of the AUTOEXEC.BAT before making any changes).

    Set the CLASSPATH to point to
    spinner\lib\spinner.jar

    For example if spinner is installed under C:\ then set CLASSPATH as (add the following line to the end of the AUTOEXEC.BAT file.)

    CLASSPATH = %CLASSPATH%;C:\spinner\lib\spinner.jar

  5. Reboot the machine for the changes to take effect.

AIX CLASSPATH

After installing the software, update the CLASSPATH environment variable as follows :

  1. Open the .profile file and set the CLASSPATH environment variable. (Be sure to take a backup of the .profile before making any changes.)
  2. Set the CLASSPATH to point to
    spinner/lib/spinner.jar

    For example if spinner is installed under the home directory then set CLASSPATH as - (add the following line to the end of the .profile file.)

    export CLASSPATH = spinner/lib/spinner.jar :$CLASSPATH

  3. Type . .profile on the command line for the changes to take effect.

OS/2 CLASSPATH

After installing the software, update the CLASSPATH environment variable as follows :

  1. Open the CONFIG.SYS file and change the CLASSPATH statement. (Be sure to make a backup of the CONFIG.SYS before making any changes.)
  2. Set the CLASSPATH to point to
    spinner\lib\spinner.jar

    For example if spinner is installed under C:\ then set CLASSPATH as (append the following to the CLASSPATH environment variable of the CONFIG.SYS file.)

    C:\spinner\lib\spinner.jar

  3. Reboot the machine for the changes to take effect.


Running the Demo Application

The demo application illustrates a part of functionality of DigitalSpinner and how to using its firing events. When users change the value or increase/decrease the current value of the spinner, the label's size in the frame increases or decreases accordingly.

The source code is shown as below(Also in the Demo directory):

import com.ibm.spinner.DigitalSpinner;
import java.awt.Frame;
import java.awt.Label;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.AWTEvent;
import java.awt.event.WindowEvent;
import java.awt.Graphics;
public class SpinnerDemo extends Frame implements ActionListener {
       private DigitalSpinner num_spin = new DigitalSpinner();
       private Label label = new Label();
       public static void main(String argv[]) {
              SpinnerDemo spins = new SpinnerDemo();
              spins.setSize(200,200);
              spins.setTitle("Spinner Demo");
              spins.show();
       }

       public SpinnerDemo() {
             enableEvents(AWTEvent.WINDOW_EVENT_MASK);
             setBackground(java.awt.Color.lightGray);
             setLayout(null); add(num_spin);
             num_spin.setBounds(30,30,50,20);
             num_spin.addActionListener(this);
             add(label);
             label.setBounds(30,60,50,50);
             label.setBackground(java.awt.Color.pink);
             label.setText((new Integer(num_spin.getCurrent())).toString());
             label.setAlignment(Label.CENTER);

        }

        public void paint(Graphics g) {
              g.drawRect(label.getBounds().x - 1, label.getBounds().y - 1, label.getBounds().width + 1,label.getBounds().height + 1);
         }

        protected void processWindowEvent(WindowEvent we) {
               if (we.getID() == WindowEvent.WINDOW_CLOSING) {
                      dispose();
                      System.exit(0);
               }
              super.processWindowEvent(we);
         }
 
         public void actionPerformed(ActionEvent act_evt) {
              int num_cur = num_spin.getCurrent();
              String act_str = act_evt.getActionCommand();
              if (act_str.equals("increment")) {
                    label.setSize(label.getBounds().width + 1,label.getBounds().height + 1);
              }
             if (act_str.equals("decrement")) {
                    label.setSize(label.getBounds().width - 1,label.getBounds().height - 1);
             }
             label.setText((new Integer(num_cur)).toString()); repaint();
        }
}

The Main Screen of the demo application is:

Input Area

Direction Buttons


Up button

References

Java Programming Language

Java Beans Specifications


Up button

Glossary of Terms

A | B | C | J

A

API 

Application Programming Interface

Application (or Applet) 

A software product that uses (includes) the Spinner component.
B

Bean 

A bean is a JavaBeans component. It is an independent, reusable software module. Beans may be visible objects, like AWT components, or invisible objects, like queues and stacks. A builder / integration tool manipulates beans to create applets and applications.
C

Component 

A piece of software isolated into a discrete, easily reusable structure.
J

Java 

An object-oriented programming language developed by Sun Microsystems. Java programs are compiled into class files that can run on any computer platform that has a Java Virtual Machine.

JavaBeans 

A portable, platform-independent component model, based on Java. The model allows creation of small, reusable, software components. A visual builder program combines components from different sources to create applications quickly and easily.

 


This document is last updated in V1.0 on 04/02/1998