package com.abl.gui; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; //SurveyController: /** part of Model-View-Controller @version 1/19/2001 @author I made this. -- prie, 8/15/98 */ final class SurveyView extends Dialog { private Button next = null; private Panel buttonBar = null; private Panel textPanel = null; private TextField textField = null; private Label textLabel = null; private String modelData = null; SurveyView(Frame parent) { super(parent, "com.abl.gui.SurveyView", true); //modal (true) Label subtitle = new Label("This is not a box"); //add subtitle subtitle.setAlignment(Label.CENTER); this.add("North", subtitle); buttonBar = new Panel(); //button(s): next = createButton("Next", "Next"); //initialize buttonBar.add(next); this.add("South", buttonBar); textPanel = new Panel(); //field(s): textField = new TextField(50); textPanel.add(textField); } void connectTo(ActionListener listener) { next.addActionListener(listener); } void displayModelData(String defaultStr) { modelData = defaultStr; if (textLabel != null) { //remove old label this.remove(textPanel); textPanel.remove(textLabel); } textLabel = new Label("(A-Z message)"); textPanel.add(textLabel); this.add("Center", textPanel); //add fields this.pack(); //make visible textField.setText(defaultStr); this.setVisible(true); } String getModelData() { modelData = textField.getText(); return modelData; } private Button createButton(String text, String command) { Button button = new Button(text); button.setActionCommand(command); return button; } }