lib/browser/awtUtilities/MessageDialog.java
author berghofe
Wed, 06 Aug 1997 00:06:47 +0200
changeset 3599 89cbba12863d
child 6541 d3ac35b2bfbf
permissions -rw-r--r--
Source files for Isabelle theory graph browser. Initial revision.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3599
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
     1
/***************************************************************************
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
     2
  Title:      awtUtilities/MessageDialog.java
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
     3
  ID:         $Id$
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
     4
  Author:     Stefan Berghofer, TU Muenchen
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
     5
  Copyright   1997  TU Muenchen
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
     6
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
     7
  This class defines a dialog window for displaying messages and buttons.
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
     8
***************************************************************************/
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
     9
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    10
package awtUtilities;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    11
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    12
import java.awt.*;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    13
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    14
public class MessageDialog extends Dialog {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    15
	String txt;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    16
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    17
	public String getText() { return txt; }
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    18
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    19
	public boolean action(Event evt, Object arg) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    20
		if (evt.target instanceof Button) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    21
			txt=(String)arg;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    22
			hide();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    23
			return true;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    24
		} else return false;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    25
	}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    26
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    27
	public MessageDialog(Frame parent,String title,String text,String []buttons) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    28
		super(parent,title,true);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    29
		int i;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    30
		Panel p1=new Panel(),p2=new Panel();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    31
		p1.setLayout(new FlowLayout(FlowLayout.CENTER,0,0));
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    32
		p2.setLayout(new FlowLayout());
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    33
		setFont(new Font("Helvetica", Font.PLAIN, 14));
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    34
		setLayout(new GridLayout(2,1));
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    35
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    36
		while (true) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    37
			int pos=text.indexOf(' ');
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    38
			if (pos<0) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    39
				p1.add(new Label(text));
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    40
				break;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    41
			} else {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    42
				p1.add(new Label(text.substring(0,pos)));
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    43
				if (pos+1==text.length())
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    44
					break;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    45
				else
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    46
					text=text.substring(pos+1);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    47
			}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    48
		}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    49
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    50
		add(p1);add(p2);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    51
		for (i=0;i<buttons.length;i++)
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    52
			p2.add(new Button(buttons[i]));
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    53
	}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    54
}