KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnet > Browser > MemoEditDialog


1 /*
2  * MemoEditDialog.java
3  *
4  * Created on 19. květen 2004, 16:23
5  */

6
7 package SOFA.SOFAnet.Browser;
8
9 import javax.swing.*;
10 import java.awt.Component JavaDoc;
11 import java.awt.Frame JavaDoc;
12
13 /**
14  *
15  * @author Ladislav Sobr
16  */

17 public class MemoEditDialog extends javax.swing.JDialog JavaDoc
18 {
19   private String JavaDoc text;
20   public static String JavaDoc showDialog(Component JavaDoc frameComp, String JavaDoc initText, String JavaDoc label, String JavaDoc title)
21   {
22     Frame JavaDoc 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   /** Creates new form MemoEditDialog */
31   public MemoEditDialog(java.awt.Frame JavaDoc parent, boolean modal, String JavaDoc initText, String JavaDoc label, String JavaDoc 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 JavaDoc getText()
42   {
43     return text;
44   }
45   
46   /** This method is called from within the constructor to
47    * initialize the form.
48    * WARNING: Do NOT modify this code. The content of this method is
49    * always regenerated by the Form Editor.
50    */

51   private void initComponents()//GEN-BEGIN:initComponents
52
{
53     jLabel = new javax.swing.JLabel JavaDoc();
54     jScrollPane1 = new javax.swing.JScrollPane JavaDoc();
55     jTextArea = new javax.swing.JTextArea JavaDoc();
56     jPanel1 = new javax.swing.JPanel JavaDoc();
57     OKButton = new javax.swing.JButton JavaDoc();
58     cancelButton = new javax.swing.JButton JavaDoc();
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 JavaDoc(24, 400));
64     jScrollPane1.setPreferredSize(new java.awt.Dimension JavaDoc(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 JavaDoc(400, 35));
71     OKButton.setText("OK");
72     OKButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
73     {
74       public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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 JavaDoc()
84     {
85       public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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   }//GEN-END:initComponents
97

98   private void cancelButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_cancelButtonActionPerformed
99
{//GEN-HEADEREND:event_cancelButtonActionPerformed
100
dispose();
101   }//GEN-LAST:event_cancelButtonActionPerformed
102

103   private void OKButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_OKButtonActionPerformed
104
{//GEN-HEADEREND:event_OKButtonActionPerformed
105
text = jTextArea.getText();
106     dispose();
107   }//GEN-LAST:event_OKButtonActionPerformed
108

109   // Variables declaration - do not modify//GEN-BEGIN:variables
110
private javax.swing.JButton JavaDoc OKButton;
111   private javax.swing.JButton JavaDoc cancelButton;
112   private javax.swing.JLabel JavaDoc jLabel;
113   private javax.swing.JPanel JavaDoc jPanel1;
114   private javax.swing.JScrollPane JavaDoc jScrollPane1;
115   private javax.swing.JTextArea JavaDoc jTextArea;
116   // End of variables declaration//GEN-END:variables
117

118 }
119
Popular Tags