/** * ColorTestDialog draws samples of all system color instances.<p> * * Copyright &copy; 1997 Martin Minow. All Rights Reserved.<p> * * Permission to use, copy, modify, and redistribute this software and its * documentation for personal, non-commercial use is hereby granted provided that * this copyright notice and appropriate documentation appears in all copies. This * software may not be distributed for fee or as part of commercial, "shareware," * and/or not-for-profit endevors including, but not limited to, CD-ROM collections, * online databases, and subscription services without specific license.<p> * * @author <a href="mailto:minow@apple.com">Martin Minow</a> * @version 1.0 * Set tabs every 4 characters. */import java.util.*;import java.awt.*;import java.awt.event.*;/** * Display all system color values. Requires Java 1.1 */class ColorTestDialog extends Dialog{	public static final int	colorWidth		= 24;public static final Font	font			= new Font("Courier", Font.PLAIN, 10);	public final String		longName		= "inactiveCaptionBorder";	protected Button			okButton		= new Button(" ok ");	protected ColorTestPanel	colorTestPanel	= new ColorTestPanel();		public ColorTestDialog(			Component			parent		)	{		super(getFrame(parent), "System Color Test", false);		setResizable(true);		/*		 * Create the OK button in a separate panel so it doesn't		 * stretch across the entire bottom of the window.		 */		Panel panel = new Panel();		panel.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 4));		panel.add(okButton);		this.setLayout(new BorderLayout(2, 2));		add("Center", colorTestPanel);		add("South", panel);		pack();		show();	}	public boolean handleEvent(			Event			event		)	{		if (event.target == okButton		 && event.id == Event.ACTION_EVENT) {			dispose();			return (true);		}		else if (event.id == Event.WINDOW_DESTROY) {			dispose();			return (true);		}		else {			/* Someone else's problem */		}		return (false);	}    public static Frame getFrame(    		Component		component    	)    {		while (component != null && !(component instanceof Frame)) {			component = component.getParent();		}		return ((Frame) component);    }}	