KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * RenameDialog.java
3  *
4  * Created on November 15, 2002, 6:42 PM
5  */

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

13 public class RenameDialog extends javax.swing.JDialog JavaDoc {
14     
15     String JavaDoc name;
16     boolean state=false;
17     
18     /** Creates new form RenameDialog */
19     public RenameDialog(java.awt.Frame JavaDoc parent, String JavaDoc name) {
20     super(parent, true);
21     this.name=name;
22     initComponents();
23     nameF.setText(name);
24     nameF.setSelectionStart(0);
25     nameF.setSelectionEnd(name.length()-1);
26     pack();
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         propertyNameL = new javax.swing.JLabel JavaDoc();
38         nameF = new javax.swing.JTextField JavaDoc();
39         jPanel2 = new javax.swing.JPanel JavaDoc();
40         renameB = new javax.swing.JButton JavaDoc();
41         stornoB = new javax.swing.JButton JavaDoc();
42
43         setTitle("Rename");
44         setModal(true);
45         setResizable(false);
46         addWindowListener(new java.awt.event.WindowAdapter JavaDoc() {
47             public void windowClosing(java.awt.event.WindowEvent JavaDoc evt) {
48                 closeDialog(evt);
49             }
50         });
51
52         jPanel1.setLayout(new java.awt.FlowLayout JavaDoc(java.awt.FlowLayout.CENTER, 10, 10));
53
54         propertyNameL.setText("New Name: ");
55         jPanel1.add(propertyNameL);
56
57         nameF.setColumns(20);
58         jPanel1.add(nameF);
59
60         getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
61
62         jPanel2.setLayout(new java.awt.FlowLayout JavaDoc(java.awt.FlowLayout.CENTER, 10, 10));
63
64         renameB.setText("Rename");
65         renameB.setSelected(true);
66         renameB.addActionListener(new java.awt.event.ActionListener JavaDoc() {
67             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
68                 renameBActionPerformed(evt);
69             }
70         });
71
72         jPanel2.add(renameB);
73
74         stornoB.setText("Storno");
75         stornoB.addActionListener(new java.awt.event.ActionListener JavaDoc() {
76             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
77                 stornoBActionPerformed(evt);
78             }
79         });
80
81         jPanel2.add(stornoB);
82
83         getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH);
84
85         pack();
86     }//GEN-END:initComponents
87

88     private void renameBActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_renameBActionPerformed
89
// Add your handling code here:
90
name=nameF.getText();
91     state=true;
92     close();
93     }//GEN-LAST:event_renameBActionPerformed
94

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

101     /** Closes the dialog */
102     private void closeDialog(java.awt.event.WindowEvent JavaDoc evt) {//GEN-FIRST:event_closeDialog
103
state=false;
104     close();
105     }//GEN-LAST:event_closeDialog
106

107     private void close() {
108     setVisible(false);
109     dispose();
110     }
111     
112     /** Getter for property state.
113      * @return Value of property state.
114      *
115      */

116     public boolean getState() {
117     return state;
118     }
119     
120     /** Getter for property name.
121      * @return Value of property name.
122      *
123      */

124     public java.lang.String JavaDoc getName() {
125     return name;
126     }
127     
128     
129     // Variables declaration - do not modify//GEN-BEGIN:variables
130
private javax.swing.JTextField JavaDoc nameF;
131     private javax.swing.JLabel JavaDoc propertyNameL;
132     private javax.swing.JButton JavaDoc renameB;
133     private javax.swing.JPanel JavaDoc jPanel2;
134     private javax.swing.JButton JavaDoc stornoB;
135     private javax.swing.JPanel JavaDoc jPanel1;
136     // End of variables declaration//GEN-END:variables
137

138 }
139
Popular Tags