1 6 7 package org.netbeans.test.editor.app.gui; 8 9 import java.awt.CardLayout ; 10 import java.awt.event.ActionEvent ; 11 import javax.swing.JComboBox ; 12 import org.netbeans.test.editor.app.core.properties.ArrayProperty; 13 14 18 public class ArrayPropertyPanel extends PropertyPanel { 19 20 Object [] values; 21 22 23 public ArrayPropertyPanel(ArrayProperty array,String 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 evt) { 34 if (!readOnly) { 36 buttonState=false; 37 oldText=button.getText(); 38 ((JComboBox )editField).setSelectedItem(property.getProperty()); 39 ((CardLayout )(getLayout())).show(this,"edit"); 40 if (evt != null) { 41 evt=new ActionEvent (this,evt.getID(),evt.getActionCommand(),evt.getModifiers()); 43 dialog.buttonPressed(evt); 44 } 45 } 46 } 47 48 protected void focusLost(java.awt.event.FocusEvent evt) { 49 buttonState=true; 51 String s=(String )((JComboBox )editField).getSelectedItem(); 52 if (s == null) 53 s=""; 54 property.setProperty(s); 55 button.setText(property.getProperty()); 56 ((CardLayout )(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 () { 65 public void focusLost(java.awt.event.FocusEvent evt) { 66 ArrayPropertyPanel.this.focusLost(evt); 67 } 68 }); 69 editField.addKeyListener(new java.awt.event.KeyAdapter () { 70 public void keyPressed(java.awt.event.KeyEvent evt) { 71 ArrayPropertyPanel.this.keyPressed(evt); 72 } 73 }); 74 add(editField, "edit"); 75 } 76 77 private void generateArrayEdit() { 78 editField=new JComboBox (values); 79 } 80 81 } 82 | Popular Tags |