/* * ========================================================================= * TestList.java -- Create Frame Interface with List of years (1991 - 1999), * months (January - December), and days (1 - 31). * * Written By : Mark Austin September 1997 * ========================================================================= */ import java.awt.*; public class TestList extends Frame { // The main method creates an instance of the class. public static void main( String args[] ) { TestList t = new TestList(); } // Define window frame. public TestList() { setLayout(new GridLayout(2,3,10,10)); // Create labels for years, months and days. Font myFont = new Font ( "Courier", Font.BOLD , 24 ); Label labelYear = new Label("Year"); labelYear.setFont( myFont ); Label labelMonth = new Label("Month"); labelMonth.setFont( myFont ); Label labelDay = new Label("Day"); labelDay.setFont( myFont ); // Create lists of years, months and days. List listYears = new List ( 9 , true ); for(int ii = 1; ii <= 9; ii++ ) { listYears.addItem("199" + ii); } List listMonths = new List ( 12 , true ); listMonths.addItem("January"); listMonths.addItem("February"); listMonths.addItem("March"); listMonths.addItem("April"); listMonths.addItem("May"); listMonths.addItem("June"); listMonths.addItem("July"); listMonths.addItem("August"); listMonths.addItem("September"); listMonths.addItem("October"); listMonths.addItem("November"); listMonths.addItem("December"); List listDays = new List ( 31 , true ); for(int ii = 1; ii <= 31; ii++ ) { listDays.addItem("" + ii); } // Add lists to the frame container. add( labelYear ); add( labelMonth ); add( labelDay ); add( listYears ); add( listMonths ); add( listDays ); // Set and display frame. setTitle("Frame Interface with Three Lists"); // Set Frame Title. resize(400,120); // Resize the frame. show(); // Display the frame. } }