// File: VertDialog.java // Classes: VertDialog // Original Author: Kedar Patankar - Alberto Medina // Date 21 Jan 1997 package uci.graphedit; import java.awt.Label; import java.awt.Button; import java.awt.TextField; import java.awt.Frame; import java.awt.Panel; import java.awt.BorderLayout; import java.awt.Event; import java.awt.Color; import java.awt.FlowLayout; import gjt.GJTDialog; import gjt.DialogClient; import gjt.ButtonPanel; /*This class provides the functionality required to get the information associated with the construction/alternation class being created from the user */ public class VertDialog extends GJTDialog { private Label _actionName; private TextField _vertex_name; private Button _execute; private Button _cancel; private String _name; public VertDialog(Frame frame,DialogClient client,String title,String name) { this(frame, client, title); _vertex_name.setText(name); _vertex_name.select(0,name.length()); } public VertDialog(Frame frame,DialogClient client,String title) { super(frame,title,client,true); _actionName = new Label("Vertex Name "); _vertex_name = new TextField(25); _execute = new Button("OK"); _cancel = new Button("Cancel"); Panel label = new Panel(); label.setLayout(new FlowLayout()); label.add(_actionName); label.add(_vertex_name); label.setBackground(Color.lightGray); ButtonPanel buttonPanel = new ButtonPanel(); buttonPanel.add(_execute); buttonPanel.add(_cancel); buttonPanel.setBackground(Color.lightGray); setLayout(new BorderLayout()); add("Center",label); add("South",buttonPanel); pack(); } public void show() { _vertex_name.requestFocus(); super.show(); } public boolean handleEvent(Event e) { switch(e.id) { case Event.WINDOW_DESTROY: close(); return true; } return super.handleEvent(e); } public boolean action(Event e, Object what) { if (e.target == _cancel) { close(); return true; } else if ((e.target == _execute)||(e.target==_vertex_name)) { if (_vertex_name.getText().length() != 0) { executeCommand(e); return true; } } return false; } public void close() { hide();dispose(); } public void executeCommand(Event e) { hide(); _name=_vertex_name.getText(); client.dialogDismissed(this); dispose(); } public String get_vertex_name() { return _name; } } /* end class VertDialog */