Java Technology Home Page
A-Z Index

Java Developer Connection(SM)
Online Training

Downloads, APIs, Documentation
Java Developer Connection
Tutorials, Tech Articles, Training
Online Support
Community Discussion
News & Events from Everywhere
Products from Everywhere
How Java Technology is Used Worldwide
 

Help is available for each task.

Task 1

Make a subclass of Panel called KeyPad. Define an array of strings containing the key labels on a phone keypad.

You'll need arrays such as

 String[] keys = { "1","2","3",
                   "4","5","6",
                   "7","8","9",
                   "*","0","#"
                 };
  Button[] b = new Button[keys.length];

Task 2

In the constructor, set the layout to be a 4 row by 3 column grid of buttons. Create and add buttons to the container with a for loop.

Use the following to set the layout:

 
 public KeyPad() {
    setLayout(new GridLayout(4,3));
    ...
  }

Return to Magercise 2

Copyright © 1998-1999 MageLang Institute. All Rights Reserved.


[ This page was updated: 16-Nov-99 ]

Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first.
Sun Microsystems, Inc.
Copyright © 1995-99 Sun Microsystems, Inc.
All Rights Reserved. Legal Terms. Privacy Policy.