1 6 7 package org.netbeans.test.editor.app.gui; 8 9 13 public class RenameDialog extends javax.swing.JDialog { 14 15 String name; 16 boolean state=false; 17 18 19 public RenameDialog(java.awt.Frame parent, String 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 35 private void initComponents() { jPanel1 = new javax.swing.JPanel (); 37 propertyNameL = new javax.swing.JLabel (); 38 nameF = new javax.swing.JTextField (); 39 jPanel2 = new javax.swing.JPanel (); 40 renameB = new javax.swing.JButton (); 41 stornoB = new javax.swing.JButton (); 42 43 setTitle("Rename"); 44 setModal(true); 45 setResizable(false); 46 addWindowListener(new java.awt.event.WindowAdapter () { 47 public void windowClosing(java.awt.event.WindowEvent evt) { 48 closeDialog(evt); 49 } 50 }); 51 52 jPanel1.setLayout(new java.awt.FlowLayout (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 (java.awt.FlowLayout.CENTER, 10, 10)); 63 64 renameB.setText("Rename"); 65 renameB.setSelected(true); 66 renameB.addActionListener(new java.awt.event.ActionListener () { 67 public void actionPerformed(java.awt.event.ActionEvent evt) { 68 renameBActionPerformed(evt); 69 } 70 }); 71 72 jPanel2.add(renameB); 73 74 stornoB.setText("Storno"); 75 stornoB.addActionListener(new java.awt.event.ActionListener () { 76 public void actionPerformed(java.awt.event.ActionEvent evt) { 77 stornoBActionPerformed(evt); 78 } 79 }); 80 81 jPanel2.add(stornoB); 82 83 getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH); 84 85 pack(); 86 } 88 private void renameBActionPerformed(java.awt.event.ActionEvent evt) { name=nameF.getText(); 91 state=true; 92 close(); 93 } 95 private void stornoBActionPerformed(java.awt.event.ActionEvent evt) { state=false; 98 close(); 99 } 101 102 private void closeDialog(java.awt.event.WindowEvent evt) { state=false; 104 close(); 105 } 107 private void close() { 108 setVisible(false); 109 dispose(); 110 } 111 112 116 public boolean getState() { 117 return state; 118 } 119 120 124 public java.lang.String getName() { 125 return name; 126 } 127 128 129 private javax.swing.JTextField nameF; 131 private javax.swing.JLabel propertyNameL; 132 private javax.swing.JButton renameB; 133 private javax.swing.JPanel jPanel2; 134 private javax.swing.JButton stornoB; 135 private javax.swing.JPanel jPanel1; 136 138 } 139 | Popular Tags |