1 package org.enhydra.dods.wizard; 2 3 import java.awt.Button ; 4 import java.awt.Dialog ; 5 import java.awt.Dimension ; 6 import java.awt.Font ; 7 import java.awt.Frame ; 8 import java.awt.GridBagConstraints ; 9 import java.awt.GridBagLayout ; 10 import java.awt.Insets ; 11 import java.awt.Label ; 12 import java.awt.Panel ; 13 import java.awt.SystemColor ; 14 import java.awt.event.ActionEvent ; 15 import java.awt.event.ActionListener ; 16 import java.awt.event.KeyAdapter ; 17 import java.awt.event.KeyEvent ; 18 import java.awt.event.WindowEvent ; 19 20 26 public class MessageDialog extends Dialog { 27 Panel mainPanel; 28 GridBagLayout gridBagLayout; 29 Label lMessage; 30 Button bOK; 31 Label lEmpty2; 32 Label lEmpty3; 33 Label lEmpty4; 34 35 43 public MessageDialog(String message, Frame frame, String title, boolean modal) { 44 super(frame, title, modal); 45 mainPanel = new Panel (); 46 gridBagLayout = new GridBagLayout (); 47 lMessage = new Label (); 48 bOK = new Button (); 49 lEmpty2 = new Label (); 50 lEmpty3 = new Label (); 51 lEmpty4 = new Label (); 52 enableEvents(64L); 53 try { 54 jbInit(); 55 lMessage.setText(message); 56 add(mainPanel); 57 pack(); 58 } catch (Exception exception) { 59 exception.printStackTrace(); 60 } 61 } 62 63 70 public MessageDialog(String message, Frame frame) { 71 this(message, frame, "", true); 72 } 73 74 81 public MessageDialog(String message, Frame frame, boolean modal) { 82 this(message, frame, "", modal); 83 } 84 85 93 public MessageDialog(String message, Frame frame, String title) { 94 this(message, frame, title, true); 95 } 96 97 private void jbInit() throws Exception { 98 mainPanel.setLayout(gridBagLayout); 99 mainPanel.setBackground(SystemColor.control); 100 mainPanel.setSize(new Dimension (500, 400)); 101 lMessage.setFont(new Font ("Dialog", 1, 12)); 102 lMessage.setAlignment(1); 103 lMessage.setText("Message"); 104 bOK.setLabel("OK"); 105 lEmpty4.setAlignment(1); 106 bOK.addActionListener(new ActionListener () { 107 public void actionPerformed(ActionEvent actionevent) { 108 bOK_actionPerformed(actionevent); 109 } 110 }); 111 bOK.addKeyListener(new KeyAdapter () { 112 public void keyPressed(KeyEvent keyevent) { 113 bOKKeyPressed(keyevent); 114 } 115 }); 116 mainPanel.add(lMessage, 117 new GridBagConstraints (0, 0, 3, 1, 0.0D, 0.0D, 10, 1, 118 new Insets (0, 0, 0, 4), 10, 30)); 119 mainPanel.add(bOK, 120 new GridBagConstraints (0, 2, 3, 1, 0.0D, 0.0D, 10, 3, 121 new Insets (0, 0, 0, 1), 29, 0)); 122 mainPanel.add(lEmpty2, 123 new GridBagConstraints (0, 0, 1, 3, 0.0D, 0.0D, 10, 1, 124 new Insets (0, 0, 0, 18), 0, 0)); 125 mainPanel.add(lEmpty3, 126 new GridBagConstraints (2, 0, 1, 3, 0.0D, 0.0D, 10, 1, 127 new Insets (0, 0, 0, 22), 0, 0)); 128 mainPanel.add(lEmpty4, 129 new GridBagConstraints (0, 3, 3, 1, 0.0D, 0.0D, 10, 1, 130 new Insets (0, 0, 0, 0), 0, 0)); 131 } 132 133 protected void processWindowEvent(WindowEvent windowevent) { 134 if (windowevent.getID() == 201) { 135 cancel(); 136 } 137 super.processWindowEvent(windowevent); 138 } 139 140 void cancel() { 141 dispose(); 142 } 143 144 void bOK_actionPerformed(ActionEvent actionevent) { 145 cancel(); 146 } 147 148 void bOKKeyPressed(KeyEvent keyevent) { 149 int i = keyevent.getKeyCode(); 150 151 if (i == 27 || i == 10) { 152 cancel(); 153 } 154 } 155 } 156 | Popular Tags |