1 /* 2 * File: ListDemo.java 3 * 4 * Create a scrolling list of fonts 5 * 6 * Copyright: Northeast Parallel Architectures Center 7 * 8 */ 9 10 import java.awt.List; 11 import java.awt.Color; 12 import java.awt.Toolkit; 13 14 public class ListDemo extends java.applet.Applet { 15 16 // Allow five visible items in the list and 17 // allow for multiple selections: 18 private List fontList = new List( 5, true ); 19 20 public void init() { 21 setBackground( Color.white ); 22 23 // Color the scrolling list: 24 Color lightBlue = new Color( 0xB0, 0xE0, 0xE6 ); 25 Color navyBlue = new Color( 0x19, 0x19, 0x70 ); 26 fontList.setBackground( lightBlue ); 27 fontList.setForeground( navyBlue ); 28 29 // Get list of system fonts: 30 Toolkit toolkit = Toolkit.getDefaultToolkit(); 31 String fonts[] = toolkit.getFontList(); 32 33 // Add fonts to the scrolling list: 34 for ( int i = 0; i < fonts.length; i++ ) { 35 fontList.addItem( fonts[i] ); 36 } 37 38 add( fontList ); 39 } 40 41 }