home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-05-08 | 1.4 KB | 65 lines |
- /*
- A basic extension of the java.awt.Dialog class
- */
-
- import java.awt.*;
-
- public class MsgDlg extends Dialog {
- void button1_Clicked(Event event) {
- // close dialog
- this.hide();
- }
-
-
- public MsgDlg(Frame parent, boolean modal) {
-
- super(parent, modal);
-
- //{{INIT_CONTROLS
- setLayout(null);
- addNotify();
- resize(insets().left + insets().right + 430,insets().top + insets().bottom + 186);
- button1 = new java.awt.Button("&OK");
- button1.reshape(insets().left + 156,insets().top + 108,127,41);
- add(button1);
- label1 = new java.awt.Label("text");
- label1.reshape(insets().left + 48,insets().top + 24,339,60);
- add(label1);
- setTitle("Dialog2");
- //}}
-
- }
-
- public MsgDlg(Frame parent, String title, boolean modal) {
- this(parent, modal);
- setTitle(title);
- }
-
- public synchronized void show() {
- Rectangle bounds = getParent().bounds();
- Rectangle abounds = bounds();
-
- move(bounds.x + (bounds.width - abounds.width)/ 2,
- bounds.y + (bounds.height - abounds.height)/2);
-
- super.show();
- }
-
- public boolean handleEvent(Event event) {
- if(event.id == Event.WINDOW_DESTROY) {
- hide();
- return true;
- }
- if (event.target == button1 && event.id == Event.ACTION_EVENT) {
- button1_Clicked(event);
- return true;
- }
- return super.handleEvent(event);
- }
-
- //{{DECLARE_CONTROLS
- java.awt.Button button1;
- java.awt.Label label1;
- //}}
- }
-