1 6 7 package org.netbeans.test.editor.app.gui; 8 9 13 public class StringPropertyEditor extends javax.swing.JDialog { 14 15 String property, value; 16 boolean state=false; 17 18 19 public StringPropertyEditor(java.awt.Frame parent, String property, String 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 35 private void initComponents() { jPanel1 = new javax.swing.JPanel (); 37 jPanel3 = new javax.swing.JPanel (); 38 jPanel4 = new javax.swing.JPanel (); 39 jPanel5 = new javax.swing.JPanel (); 40 jPanel6 = new javax.swing.JPanel (); 41 editor = new javax.swing.JEditorPane (); 42 jPanel2 = new javax.swing.JPanel (); 43 okB = new javax.swing.JButton (); 44 cancelB = new javax.swing.JButton (); 45 46 setTitle("Edit Property"); 47 addWindowListener(new java.awt.event.WindowAdapter () { 48 public void windowClosing(java.awt.event.WindowEvent evt) { 49 closeDialog(evt); 50 } 51 }); 52 53 jPanel1.setLayout(new java.awt.BorderLayout (5, 5)); 54 55 jPanel1.setBorder(new javax.swing.border.EtchedBorder ()); 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 (java.awt.FlowLayout.CENTER, 20, 5)); 69 70 okB.setText("OK"); 71 okB.addActionListener(new java.awt.event.ActionListener () { 72 public void actionPerformed(java.awt.event.ActionEvent evt) { 73 okBActionPerformed(evt); 74 } 75 }); 76 77 jPanel2.add(okB); 78 79 cancelB.setText("Cancel"); 80 cancelB.addActionListener(new java.awt.event.ActionListener () { 81 public void actionPerformed(java.awt.event.ActionEvent evt) { 82 cancelBActionPerformed(evt); 83 } 84 }); 85 86 jPanel2.add(cancelB); 87 88 getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH); 89 90 pack(); 91 } 93 private void cancelBActionPerformed(java.awt.event.ActionEvent evt) { state=false; 96 close(); 97 } 99 private void okBActionPerformed(java.awt.event.ActionEvent evt) { state=true; 102 value=editor.getText(); 103 close(); 104 } 106 107 private void closeDialog(java.awt.event.WindowEvent evt) { close(); 109 } 111 private void close() { 112 setVisible(false); 113 dispose(); 114 } 115 116 120 public java.lang.String getValue() { 121 return value; 122 } 123 124 public boolean getState() { 125 return state; 126 } 127 private javax.swing.JButton cancelB; 129 private javax.swing.JPanel jPanel4; 130 private javax.swing.JPanel jPanel3; 131 private javax.swing.JPanel jPanel2; 132 private javax.swing.JPanel jPanel5; 133 private javax.swing.JEditorPane editor; 134 private javax.swing.JPanel jPanel1; 135 private javax.swing.JPanel jPanel6; 136 private javax.swing.JButton okB; 137 139 } 140 | Popular Tags |