/* * cs101 QueryDialog * $Id: QueryDialog.java,v 1.1.1.1 2002/06/05 21:56:32 root Exp $ * * Developed for "Rethinking CS101", a project of Lynn Andrea Stein's AP Group. * For more information, see the * CS101 homepage or email . * * Copyright (C) 1996 Massachusetts Institute of Technology. * Please do not redistribute without obtaining permission. */ package cs101.awt; import java.awt.*; import java.awt.event.*; /** * A class to display a toplevel dialog box with a message, * a list of "things" and associated textfields, and get answers. * *

Copyright (c) 1998 Massachusetts Institute of Technology * * @author Todd C. Parnell, tparnell@ai.mit.edu * @author * @version $Id: QueryDialog.java,v 1.1.1.1 2002/06/05 21:56:32 root Exp $ */ public class QueryDialog extends Frame { private String message; private String[] fields,values; private TextComponent[] entries; private Button ok; /** Create a hidden QueryDialog with the appropriate text and defaults. */ public QueryDialog(String message, String[] fields, String[] values) { this.message=message; this.fields=fields; this.values=values; } /** Display the dialog box, and block until the OK button is checked. */ public synchronized String[] ask() { Label l; int i; this.removeAll(); GridBagLayout gridbag = new GridBagLayout(); this.setLayout(gridbag); GridBagConstraints gbc,gblabel,gbarea; gbc = new GridBagConstraints(); gblabel = new GridBagConstraints(); gbarea = new GridBagConstraints(); gbc.gridwidth=1; gbc.gridheight=1; gbc.fill=GridBagConstraints.BOTH; gbc.weightx=1; gbc.weighty=1; gblabel=(GridBagConstraints) gbc.clone(); gbarea=(GridBagConstraints) gbc.clone(); gbarea.gridwidth=GridBagConstraints.REMAINDER; gblabel.gridwidth=GridBagConstraints.RELATIVE; gbc.gridwidth=GridBagConstraints.REMAINDER; String[] lines = getLines(message); for(i=0;i