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.JPanel ; 64 import javax.swing.JSeparator ; 65 import javax.swing.JTextField ; 66 import javax.swing.KeyStroke ; 67 import javax.swing.SwingConstants ; 68 import javax.swing.SwingUtilities ; 69 import javax.swing.border.Border ; 70 import javax.swing.text.Keymap ; 71 72 73 80 public class CreateQueueDialog extends BaseDialog { 81 82 private JPanel jPanel1; 84 private JButton okButton; 85 private JButton cancelButton; 86 private JPanel jPanel2; 87 private JSeparator jSeparator2; 88 private JLabel jLabel1; 89 90 static private CreateQueueDialog instance_; 92 93 94 99 public CreateQueueDialog(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 queue name"); 115 displayText = new JTextField (); 116 jSeparator2 = new JSeparator (); 117 setTitle("Create Administered Queue"); 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 queue 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 displayCreateQueue() { 178 displayText.setText(""); 179 180 setLocationRelativeTo(getParent()); 181 status_ = CANCELED; 182 setVisible(true); 183 184 SwingUtilities.invokeLater(new Runnable () { 185 186 public void run() { 187 cancelButton.requestFocus(); 188 } 189 } 190 ); 191 } 192 193 200 public static CreateQueueDialog instance() { 201 return instance_; 202 } 203 204 211 public static CreateQueueDialog create(JFrame parent) { 212 if (instance_ == null) { 213 instance_ = new CreateQueueDialog(parent); 214 } 215 return instance_; 216 } 217 } 218 | Popular Tags |