// File: ContentDialog.java // Classes: ContentDialog // Original Author: Kedar Patankar // Date 21 Jan 1997 package uci.graphedit; import java.awt.Button; import java.awt.Event; import java.awt.List; import java.awt.Frame; import java.awt.Panel; import java.awt.Label; import java.awt.Color; import java.awt.BorderLayout; import gjt.DialogClient; import gjt.GJTDialog; import gjt.ButtonPanel; public class ContentDialog extends GJTDialog { private Button _execute; private Button _cancel; private List _topicList; public ContentDialog(Frame frame,DialogClient dialogClient,String title) { super(frame,title,dialogClient,true); _execute = new Button("Display"); _cancel = new Button("Close"); _topicList = new List(); Panel topicPanel = new Panel(); topicPanel.setLayout(new BorderLayout()); Label l = new Label("Select the Topic"); topicPanel.add("North",l); topicPanel.add("Center",_topicList); topicPanel.setBackground(Color.lightGray); _topicList.setBackground(Color.white); ButtonPanel _buttonPanel= new ButtonPanel(); _buttonPanel.add(_execute); _buttonPanel.add(_cancel); _buttonPanel.setBackground(Color.lightGray); setLayout(new BorderLayout()); add("Center",topicPanel); add("South",_buttonPanel); fillList(); pack(); resize( 350,150); _topicList.select(0); } public void fillList() { _topicList.addItem("How to use class dictionary file(*.cd)"); _topicList.addItem("How to use Cd Draw file(*.gcd)"); _topicList.addItem("How to create new components"); _topicList.addItem("How to manage the components"); _topicList.addItem("How to print"); _topicList.addItem("How to save the work"); } public void show() { _topicList.requestFocus(); super.show(); } public boolean handleEvent(Event e) { switch(e.id) { case Event.WINDOW_DESTROY: close(); return true; case Event.LIST_SELECT: 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) { executeCommand(e); return true; } return false; } public void close() { hide(); dispose(); } protected void executeCommand(Event e) { int index=_topicList.getSelectedIndex(); String name=_topicList.getSelectedItem(); client.dialogDismissed(this); HelpFrame f=new HelpFrame(index,name); f.resize(350,400); hide(); f.show(); dispose(); } } /* end class ContentDialog */