1 6 7 package SOFA.SOFAnet.Browser; 8 9 import javax.swing.*; 10 import java.awt.Component ; 11 import java.awt.Frame ; 12 13 17 public class MemoEditDialog extends javax.swing.JDialog 18 { 19 private String text; 20 public static String showDialog(Component frameComp, String initText, String label, String title) 21 { 22 Frame frame = JOptionPane.getFrameForComponent(frameComp); 23 MemoEditDialog dialog = new MemoEditDialog(frame, true, initText, label, title); 24 dialog.setLocationRelativeTo(frameComp); 25 dialog.setVisible(true); 26 return dialog.getText(); 27 } 28 29 30 31 public MemoEditDialog(java.awt.Frame parent, boolean modal, String initText, String label, String title) 32 { 33 super(parent, modal); 34 text = null; 35 initComponents(); 36 setTitle(title); 37 jLabel.setText(label); 38 jTextArea.setText(initText); 39 } 40 41 public String getText() 42 { 43 return text; 44 } 45 46 51 private void initComponents() { 53 jLabel = new javax.swing.JLabel (); 54 jScrollPane1 = new javax.swing.JScrollPane (); 55 jTextArea = new javax.swing.JTextArea (); 56 jPanel1 = new javax.swing.JPanel (); 57 OKButton = new javax.swing.JButton (); 58 cancelButton = new javax.swing.JButton (); 59 60 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); 61 getContentPane().add(jLabel, java.awt.BorderLayout.NORTH); 62 63 jScrollPane1.setMinimumSize(new java.awt.Dimension (24, 400)); 64 jScrollPane1.setPreferredSize(new java.awt.Dimension (4, 400)); 65 jScrollPane1.setRequestFocusEnabled(false); 66 jScrollPane1.setViewportView(jTextArea); 67 68 getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER); 69 70 jPanel1.setPreferredSize(new java.awt.Dimension (400, 35)); 71 OKButton.setText("OK"); 72 OKButton.addActionListener(new java.awt.event.ActionListener () 73 { 74 public void actionPerformed(java.awt.event.ActionEvent evt) 75 { 76 OKButtonActionPerformed(evt); 77 } 78 }); 79 80 jPanel1.add(OKButton); 81 82 cancelButton.setText("Cancel"); 83 cancelButton.addActionListener(new java.awt.event.ActionListener () 84 { 85 public void actionPerformed(java.awt.event.ActionEvent evt) 86 { 87 cancelButtonActionPerformed(evt); 88 } 89 }); 90 91 jPanel1.add(cancelButton); 92 93 getContentPane().add(jPanel1, java.awt.BorderLayout.SOUTH); 94 95 pack(); 96 } 98 private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) { dispose(); 101 } 103 private void OKButtonActionPerformed(java.awt.event.ActionEvent evt) { text = jTextArea.getText(); 106 dispose(); 107 } 109 private javax.swing.JButton OKButton; 111 private javax.swing.JButton cancelButton; 112 private javax.swing.JLabel jLabel; 113 private javax.swing.JPanel jPanel1; 114 private javax.swing.JScrollPane jScrollPane1; 115 private javax.swing.JTextArea jTextArea; 116 118 } 119 | Popular Tags |