01: // @(#)NetletErrorDialog.java 1.5 "@(#)NetletErrorDialog.java 1.5 01/01/30 Sun Microsystems"
02:
03: package com.sun.portal.netlet.client.common;
04:
05: import java.awt.*;
06: import java.awt.event.ActionListener;
07: import java.awt.event.ActionEvent;
08:
09: public class NetletErrorDialog extends Dialog {
10:
11: public Button okButton;
12: private Label l;
13:
14: public NetletErrorDialog(Frame f, ActionListener a, String title,
15: String text) {
16: // Netlet Error
17: super (f, (title == null ? ResourceProperties.getString("ned.1")
18: : title));
19:
20: GridBagLayout gb = new GridBagLayout();
21: GridBagConstraints gc = new GridBagConstraints();
22: setLayout(gb);
23: gc.fill = GridBagConstraints.NONE;
24: gc.gridwidth = GridBagConstraints.REMAINDER;
25: gc.gridheight = 1;
26: gc.gridwidth = 1;
27:
28: gc.gridx = 0;
29: gc.gridy = 0;
30: String msg;
31: if (text == null || text.length() == 0) {
32: msg = ResourceProperties.getString("ned.2"); // Unknown Error
33: } else {
34: msg = text;
35: }
36:
37: l = new Label(msg, Label.CENTER);
38: gc.insets = new Insets(10, 5, 5, 5);
39: gb.setConstraints(l, gc);
40: add(l);
41:
42: gc.gridx = 0;
43: gc.gridy = 1;
44:
45: okButton = new Button(ResourceProperties.getString("ned.3")); // OK
46: okButton.setActionCommand("OK");
47: okButton.addActionListener(a);
48: gb.setConstraints(okButton, gc);
49: add(okButton);
50:
51: pack();
52:
53: Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
54: Point p = new Point();
55: p.x = (d.width / 6);
56: p.y = (d.height / 6);
57: setLocation(p);
58: }
59:
60: public void setErrorMessage(String msg) {
61: if (msg != null) {
62: l.setText(msg);
63: // resize to message
64: pack();
65: }
66: }
67:
68: synchronized public void waitForAction() {
69: try {
70: wait();
71: } catch (InterruptedException e) {
72: }
73: }
74:
75: synchronized public void notifyAction() {
76: notify();
77: }
78: }
|