KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * ArrayPropertyPanel.java
3  *
4  * Created on November 18, 2002, 5:39 PM
5  */

6
7 package org.netbeans.test.editor.app.gui;
8
9 import java.awt.CardLayout JavaDoc;
10 import java.awt.event.ActionEvent JavaDoc;
11 import javax.swing.JComboBox JavaDoc;
12 import org.netbeans.test.editor.app.core.properties.ArrayProperty;
13
14 /**
15  *
16  * @author eh103527
17  */

18 public class ArrayPropertyPanel extends PropertyPanel {
19     
20     Object JavaDoc[] values;
21     
22     /** Creates a new instance of ArrayPropertyPanel */
23     public ArrayPropertyPanel(ArrayProperty array,String JavaDoc name) {
24         propertyName=name;
25         property=array;
26         values=array.getValues();
27         initComponents();
28         generateEdit();
29         button.setText(property.getProperty());
30         oldText=button.getText();
31     }
32     
33     protected void buttonPressed(java.awt.event.ActionEvent JavaDoc evt) {
34         // Add your handling code here:
35
if (!readOnly) {
36             buttonState=false;
37             oldText=button.getText();
38             ((JComboBox JavaDoc)editField).setSelectedItem(property.getProperty());
39             ((CardLayout JavaDoc)(getLayout())).show(this,"edit");
40             if (evt != null) {
41                 // evt.setSource(this);
42
evt=new ActionEvent JavaDoc(this,evt.getID(),evt.getActionCommand(),evt.getModifiers());
43                 dialog.buttonPressed(evt);
44             }
45         }
46     }
47     
48     protected void focusLost(java.awt.event.FocusEvent JavaDoc evt) {
49         // Add your handling code here:
50
buttonState=true;
51         String JavaDoc s=(String JavaDoc)((JComboBox JavaDoc)editField).getSelectedItem();
52         if (s == null)
53             s="";
54         property.setProperty(s);
55         button.setText(property.getProperty());
56         ((CardLayout JavaDoc)(getLayout())).show(this,"button");
57         if (button.getText().compareTo(oldText) != 0) {
58             dialog.propertyChanged(propertyName,property);
59         }
60     }
61     
62     protected void generateEdit() {
63         generateArrayEdit();
64         editField.addFocusListener(new java.awt.event.FocusAdapter JavaDoc() {
65             public void focusLost(java.awt.event.FocusEvent JavaDoc evt) {
66                 ArrayPropertyPanel.this.focusLost(evt);
67             }
68         });
69         editField.addKeyListener(new java.awt.event.KeyAdapter JavaDoc() {
70             public void keyPressed(java.awt.event.KeyEvent JavaDoc evt) {
71                 ArrayPropertyPanel.this.keyPressed(evt);
72             }
73         });
74         add(editField, "edit");
75     }
76     
77     private void generateArrayEdit() {
78         editField=new JComboBox JavaDoc(values);
79     }
80     
81 }
82
Popular Tags