KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > editor > app > gui > StringPropertyEditor


1 /*
2  * StringPropertyEditor.java
3  *
4  * Created on December 10, 2002, 4:08 PM
5  */

6
7 package org.netbeans.test.editor.app.gui;
8
9 /**
10  *
11  * @author eh103527
12  */

13 public class StringPropertyEditor extends javax.swing.JDialog JavaDoc {
14     
15     String JavaDoc property, value;
16     boolean state=false;
17     
18     /** Creates new form StringPropertyEditor */
19     public StringPropertyEditor(java.awt.Frame JavaDoc parent, String JavaDoc property, String JavaDoc value) {
20         super(parent, true);
21         this.property=property;
22         this.value=value;
23         initComponents();
24         setTitle(getTitle()+" ["+property+"]");
25         editor.setText(value);
26         setSize(320,240);
27         setLocation(parent.getX()+(parent.getWidth()-getWidth())/2,parent.getY()+(parent.getHeight()-getHeight())/2);
28     }
29     
30     /** This method is called from within the constructor to
31      * initialize the form.
32      * WARNING: Do NOT modify this code. The content of this method is
33      * always regenerated by the Form Editor.
34      */

35     private void initComponents() {//GEN-BEGIN:initComponents
36
jPanel1 = new javax.swing.JPanel JavaDoc();
37         jPanel3 = new javax.swing.JPanel JavaDoc();
38         jPanel4 = new javax.swing.JPanel JavaDoc();
39         jPanel5 = new javax.swing.JPanel JavaDoc();
40         jPanel6 = new javax.swing.JPanel JavaDoc();
41         editor = new javax.swing.JEditorPane JavaDoc();
42         jPanel2 = new javax.swing.JPanel JavaDoc();
43         okB = new javax.swing.JButton JavaDoc();
44         cancelB = new javax.swing.JButton JavaDoc();
45
46         setTitle("Edit Property");
47         addWindowListener(new java.awt.event.WindowAdapter JavaDoc() {
48             public void windowClosing(java.awt.event.WindowEvent JavaDoc evt) {
49                 closeDialog(evt);
50             }
51         });
52
53         jPanel1.setLayout(new java.awt.BorderLayout JavaDoc(5, 5));
54
55         jPanel1.setBorder(new javax.swing.border.EtchedBorder JavaDoc());
56         jPanel1.add(jPanel3, java.awt.BorderLayout.NORTH);
57
58         jPanel1.add(jPanel4, java.awt.BorderLayout.SOUTH);
59
60         jPanel1.add(jPanel5, java.awt.BorderLayout.EAST);
61
62         jPanel1.add(jPanel6, java.awt.BorderLayout.WEST);
63
64         jPanel1.add(editor, java.awt.BorderLayout.CENTER);
65
66         getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
67
68         jPanel2.setLayout(new java.awt.FlowLayout JavaDoc(java.awt.FlowLayout.CENTER, 20, 5));
69
70         okB.setText("OK");
71         okB.addActionListener(new java.awt.event.ActionListener JavaDoc() {
72             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
73                 okBActionPerformed(evt);
74             }
75         });
76
77         jPanel2.add(okB);
78
79         cancelB.setText("Cancel");
80         cancelB.addActionListener(new java.awt.event.ActionListener JavaDoc() {
81             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
82                 cancelBActionPerformed(evt);
83             }
84         });
85
86         jPanel2.add(cancelB);
87
88         getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH);
89
90         pack();
91     }//GEN-END:initComponents
92

93     private void cancelBActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_cancelBActionPerformed
94
// Add your handling code here:
95
state=false;
96         close();
97     }//GEN-LAST:event_cancelBActionPerformed
98

99     private void okBActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_okBActionPerformed
100
// Add your handling code here:
101
state=true;
102         value=editor.getText();
103         close();
104     }//GEN-LAST:event_okBActionPerformed
105

106     /** Closes the dialog */
107     private void closeDialog(java.awt.event.WindowEvent JavaDoc evt) {//GEN-FIRST:event_closeDialog
108
close();
109     }//GEN-LAST:event_closeDialog
110

111     private void close() {
112         setVisible(false);
113         dispose();
114     }
115     
116     /** Getter for property value.
117      * @return Value of property value.
118      *
119      */

120     public java.lang.String JavaDoc getValue() {
121         return value;
122     }
123     
124     public boolean getState() {
125         return state;
126     }
127     // Variables declaration - do not modify//GEN-BEGIN:variables
128
private javax.swing.JButton JavaDoc cancelB;
129     private javax.swing.JPanel JavaDoc jPanel4;
130     private javax.swing.JPanel JavaDoc jPanel3;
131     private javax.swing.JPanel JavaDoc jPanel2;
132     private javax.swing.JPanel JavaDoc jPanel5;
133     private javax.swing.JEditorPane JavaDoc editor;
134     private javax.swing.JPanel JavaDoc jPanel1;
135     private javax.swing.JPanel JavaDoc jPanel6;
136     private javax.swing.JButton JavaDoc okB;
137     // End of variables declaration//GEN-END:variables
138

139 }
140
Popular Tags