magazine resources subscribe about advertising

New Architect Daily
Commentary and updates on current events and technologies

CMP Media E-Book

Download your copy today.

Research
Search for reports and white papers from industry vendors and analysts.

This Week at NewArchitect.com Subscribe now to our free email newsletter and get notified when the site is updated with new articles







Day of Defeat Online Gaming

 New Architect > Archives > 1998 > 06 > Java@Work  

A SpinField Data-Entry Component

A common data-entry component available in most modern windowing environments, but missing in Java, is the spin-button field. A spin-button field lets the user enter data into a single text field and also increment or decrement the value with up/down buttons; see Figure 1. In this article, I'll construct a SpinField object, and along the way, show you how to build a Java interface and create a couple of other useful buttons for your thermos of Java tricks.

The Wish List

The first step in any coding exercise is to write down some specifications. This spec doesn't have to be overly formal. I simply start by writing down what I want the code to do:

  • The SpinField has button-like behavior.
  • The up/down buttons can have images for labels.
  • The button has "type-o-matic" characteristics.
  • The value in the text field increments/decrements when an up/down button is pushed.

The first wish implies that the new SpinField can be dropped into an applet just like a standard button object, and that it will communicate with the rest of the software in the same manner (through events). "Button-like" also means that it can receive focus.

The images-for-labels wish means we can create buttons with icons.




  Day of Defeat Online Gaming

home | daily | current issue | archives | features | critical decisions | case studies | expert opinion | reviews | access | industry events | newsletter | research | careers | info centers | advertising | subscribe | subscriber service | editorial calendar | press | contacts


Copyright © 2006 CMP Media, LLC Read our privacy policy, your California privacy rights, terms of service.
SDMG Web sites: BYTE.com, C/C++ Users Journal, Developer Pipeline, Dr. Dobb's Journal, DotNetJunkies, MSDN Magazine, Sys Admin,
SD Expo, SD Magazine, SqlJunkies, The Perl Journal, Unixreview, Windows Developer Network, New Architect

web2