home *** CD-ROM | disk | FTP | other *** search
- $$IF(comments)
- ///////////////////////////////////////////////////////////////////////////////
- //
- // Java Source: Alert.java
- // Description: Alert box (MessageBox) functionality
- //
-
- $$ENDIF
- import java.awt.*;
-
- $$IF(comments)
- /**
- * Alert dialog class
- */
- $$ENDIF
- public class Alert extends Dialog
- {
- $$IF(comments)
- /**
- * OK button
- */
- $$ENDIF
- protected Button buttonOK;
-
- $$IF(comments)
- /**
- * Constructs an alert dialog.
- * @param parent Frame that owns this dialog
- * @param title Title of alert dialog
- * @param text Text to show in dialog
- */
- $$ENDIF
- public Alert(Frame parent, String title, String text)
- {
- super(parent, title, true);
- GridBagLayout gb = new GridBagLayout();
- setLayout(gb);
- GridBagConstraints c = new GridBagConstraints();
- c.gridx = 0;
- c.insets = new Insets(10, 10, 10, 10);
- Label l;
- add(l = new Label(text));
- gb.setConstraints(l, c);
- add(buttonOK = new Button("OK"));
- gb.setConstraints(buttonOK, c);
- setResizable(false);
- pack();
- Rectangle rcParent = parent.bounds();
- Dimension dAlert = size();
- move
- (
- rcParent.x + (rcParent.width - dAlert.width) / 2,
- rcParent.y + (rcParent.height - dAlert.height) / 2
- );
- show();
- }
-
- $$IF(comments)
- /**
- * This method is called when an action occurs inside this component.
- * @param e Event class with information about the action.
- * @param o Argument object.
- * @return True if the event was handled, false otherwise
- */
- $$ENDIF
- public boolean action(Event e, Object o)
- {
- if (e.target == buttonOK)
- {
- dispose();
- return true;
- }
- return false;
- }
- }
-
- $$IF(comments)
- ///////////////////////////////// End of File /////////////////////////////////
- $$ENDIF
-