1 48 49 package org.exolab.jms.tools.admin; 50 51 import java.awt.BorderLayout ; 52 import java.awt.FlowLayout ; 53 import java.awt.event.ActionEvent ; 54 import java.awt.event.ActionListener ; 55 import java.awt.event.KeyEvent ; 56 import java.awt.event.WindowAdapter ; 57 import java.awt.event.WindowEvent ; 58 59 import javax.swing.BorderFactory ; 60 import javax.swing.JButton ; 61 import javax.swing.JFrame ; 62 import javax.swing.JLabel ; 63 import javax.swing.JOptionPane ; 64 import javax.swing.JPanel ; 65 import javax.swing.JSeparator ; 66 import javax.swing.JTextField ; 67 import javax.swing.KeyStroke ; 68 import javax.swing.SwingConstants ; 69 import javax.swing.SwingUtilities ; 70 import javax.swing.border.Border ; 71 import javax.swing.text.Keymap ; 72 73 74 81 public class CreateTopicDialog extends BaseDialog { 82 83 private JPanel jPanel1; 85 private JButton okButton; 86 private JButton cancelButton; 87 private JPanel jPanel2; 88 private JSeparator jSeparator2; 89 private JLabel jLabel1; 90 91 static private CreateTopicDialog instance_; 93 94 99 public CreateTopicDialog(JFrame parent) { 100 super(parent); 101 } 102 103 108 protected void initComponents() { 109 jPanel1 = new JPanel (); 110 okButton = new JButton (); 111 cancelButton = new JButton (); 112 jPanel2 = new JPanel (); 113 jLabel1 = new JLabel (); 114 jLabel1.setText("Enter the topic name"); 115 displayText = new JTextField (); 116 jSeparator2 = new JSeparator (); 117 setTitle("Create Administered Topic"); 118 setModal(true); 119 setResizable(true); 120 addWindowListener(new WindowAdapter () { 121 122 public void windowClosing(WindowEvent evt) { 123 closeDialog(evt); 124 } 125 } 126 ); 127 128 jPanel1.setLayout(new FlowLayout (1, 50, 10)); 129 okButton.setToolTipText("Press to confirm Action"); 130 okButton.setText("OK"); 131 getRootPane().setDefaultButton(okButton); 132 jPanel1.add(okButton); 133 cancelButton.setToolTipText("Press to abort Action"); 134 cancelButton.setText("Cancel"); 135 jPanel1.add(cancelButton); 136 getContentPane().add(jPanel1, BorderLayout.SOUTH); 137 jPanel2.setLayout(new BorderLayout (0, 15)); 138 displayText.setToolTipText 139 ("Enter the unique topic name for this object"); 140 141 Border loweredbevel = BorderFactory.createLoweredBevelBorder(); 142 displayText.setBorder(loweredbevel); 143 displayText.setEditable(true); 144 displayText.setText(""); 145 displayText.setHorizontalAlignment(SwingConstants.LEFT); 146 jPanel2.add(jLabel1, BorderLayout.NORTH); 147 jPanel2.add(displayText, BorderLayout.CENTER); 148 jPanel2.add(jSeparator2, BorderLayout.SOUTH); 149 getContentPane().add(jPanel2, BorderLayout.CENTER); 150 151 okButton.addActionListener(new ActionListener () { 152 153 public void actionPerformed(ActionEvent evt) { 154 confirm(); 155 } 156 } 157 ); 158 159 cancelButton.addActionListener(new ActionListener () { 160 161 public void actionPerformed(ActionEvent evt) { 162 cancel(); 163 } 164 } 165 ); 166 167 KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); 170 Keymap km = displayText.getKeymap(); 171 km.removeKeyStrokeBinding(enter); 172 } 173 174 177 public void displayCreateTopic() { 178 displayText.setText(""); 179 setLocationRelativeTo(getParent()); 180 status_ = CANCELED; 181 setVisible(true); 182 183 SwingUtilities.invokeLater(new Runnable () { 184 185 public void run() { 186 cancelButton.requestFocus(); 187 } 188 } 189 ); 190 } 191 192 195 public void displayCreateConsumer() { 196 name_ = JOptionPane.showInputDialog 197 (getParent(), "Enter a unique consumer name", 198 "OpenJMS Consumer Creation", JOptionPane.PLAIN_MESSAGE); 199 if (name_ == null || name_.equals("")) { 200 status_ = CANCELED; 201 } else { 202 status_ = CONFIRMED; 203 } 204 } 205 206 213 public static CreateTopicDialog instance() { 214 return instance_; 215 } 216 217 224 public static CreateTopicDialog create(JFrame parent) { 225 if (instance_ == null) { 226 instance_ = new CreateTopicDialog(parent); 227 } 228 return instance_; 229 } 230 } 231 | Popular Tags |