1 32 33 package it.businesslogic.ireport.gui.sheet; 34 35 import it.businesslogic.ireport.gui.event.SheetPropertyValueChangedEvent; 36 import java.util.*; 37 import javax.swing.*; 38 import it.businesslogic.ireport.util.*; 39 40 public class ComboBoxSheetProperty extends SheetProperty { 41 42 public ComboBoxSheetProperty(String key, String name) { 43 super( key, name, SheetProperty.COMBOBOX); 44 } 45 46 public Object getEditorValue(JComponent component) 47 { 48 return ((JComboBox)component).getSelectedItem(); 49 } 50 51 public void setEditorValue(JComponent component, Object str) 52 { 53 try { 54 ((JComboBox)component).setSelectedItem(str); 55 } catch (Exception ex) { 56 ex.printStackTrace(); 57 } 58 } 59 60 public void actionPerformed(java.awt.event.ActionEvent event) 61 { 62 if (isSetting()) return; 63 Object new_value = getEditorValue( this.getEditor() ); 64 if (new_value != null && new_value.equals(value)) return; 65 66 Object oldValue = value; 67 value = new_value; 68 if(oldValue == null || value == null) 70 { 71 updateLabel(); 72 } 73 74 fireSheetPropertyValueChangedListenerSheetPropertyValueChanged( 75 new SheetPropertyValueChangedEvent(getKeyName(),oldValue,value, this)); 76 } 77 78 public void updateValues(Vector values, boolean addNullEntry){ 79 80 81 Misc.updateComboBox( (JComboBox)getEditor(), values, addNullEntry); 82 83 } 84 } 85 | Popular Tags |