1 48 49 package org.exolab.jms.tools.admin; 50 51 import java.awt.event.WindowEvent ; 52 53 import javax.swing.JDialog ; 54 import javax.swing.JFrame ; 55 import javax.swing.JOptionPane ; 56 import javax.swing.JTextField ; 57 58 59 73 abstract public class BaseDialog extends JDialog { 74 75 protected String name_; 77 78 protected JTextField displayText; 80 81 final static public int CANCELED = 1; 83 final static public int CONFIRMED = 2; 84 85 protected int status_; 87 88 89 94 BaseDialog(JFrame parent) { 95 super(parent, true); 96 initComponents(); 97 pack(); 98 } 99 100 104 protected abstract void initComponents(); 105 106 112 protected void closeDialog(WindowEvent evt) { 113 setVisible(false); 114 dispose(); 115 } 116 117 123 public boolean isConfirmed() { 124 return status_ == CONFIRMED; 125 } 126 127 132 public String getName() { 133 return name_; 134 } 135 136 144 protected void confirm() { 145 name_ = displayText.getText(); 146 147 if (name_ == null || name_.equals("")) { 148 JOptionPane.showMessageDialog 149 (this, "A name must be suplied", "Create Error", 150 JOptionPane.ERROR_MESSAGE); 151 } else { 152 status_ = CONFIRMED; 153 setVisible(false); 154 dispose(); 155 } 156 } 157 158 163 protected void cancel() { 164 status_ = CANCELED; 165 setVisible(false); 166 dispose(); 167 } 168 169 } | Popular Tags |