// File: AlarmDialog.java // Classes: AlarmDialog // Original Author: Kedar Patankar // Date : 21 Jan 1997 package uci.graphedit; import java.awt.Button; import java.awt.Frame; import java.awt.Label; import java.awt.BorderLayout; import java.awt.Event; import java.awt.Font; import java.awt.Color; import gjt.GJTDialog; import gjt.DialogClient; import gjt.ButtonPanel; public class AlarmDialog extends GJTDialog { private Button _yes; private Button _no; private Button _cancel; private String _choice; public AlarmDialog(Frame frame,DialogClient dialogClient,String title,String file) { super(frame,title,dialogClient,true); setLayout(new BorderLayout()); Label alarmFile=new Label(file,Label.CENTER); Label alarmQuestion = new Label("Save changes to class graph?",Label.CENTER); add("North",alarmQuestion); add("Center",alarmFile); alarmQuestion.setFont(new Font("Times Roman",Font.BOLD,12)); ButtonPanel buttonPanel= new ButtonPanel(); buttonPanel.add(_yes = new Button("Yes")); buttonPanel.add(_no = new Button("No")); buttonPanel.add(_cancel=new Button("Cancel")); buttonPanel.setBackground(Color.lightGray); add("South",buttonPanel); pack(); setBackground(Color.lightGray); } public void show() { _yes.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 == _no) { _choice="NO"; executecommand(); return true; } else if(e.target == _yes) { _choice="YES"; executecommand(); return true; } return false; } public void close() { hide(); dispose(); } private void executecommand() { hide(); client.dialogDismissed(this); dispose(); } public String getChoice(){return _choice;} } /* end class AlarmDialog */