1 6 7 package com.nqadmin.swingSet.formatting; 8 9 import java.awt.BorderLayout ; 10 import java.awt.event.ActionListener ; 11 import java.beans.*; 12 import javax.swing.JComboBox ; 13 import javax.swing.JLabel ; 14 import javax.swing.JPanel ; 15 16 19 public class SSFormattedTextFieldColumnNamePropertyEditor extends PropertyEditorSupport implements ActionListener { 20 21 private String cn = "<none>"; 22 23 public SSFormattedTextFieldColumnNamePropertyEditor() { 24 super(); 25 cn = new String ("<none>"); 26 } 27 28 public boolean supportsCustomEditor() { 29 return true; 30 } 31 32 public String [] getTags() { 33 34 String [] retValue = { 35 "<none>", 36 "account_id", 37 "account_name", 38 "currency_id", 39 "instructions" 40 }; 41 return retValue; 42 } 43 44 public void setAsText(String sValue) { 45 cn = sValue; 46 setValue(cn); 47 firePropertyChange(); 48 } 49 50 public String getAsText() { 51 return cn; 52 } 53 54 public String getJavaInitializationString() { 55 String is = null; 56 57 if (cn == "<none>") return null; 58 59 is = "\"" + cn + "\""; 60 61 return is; 62 } 63 64 65 public java.awt.Component getCustomEditor() { 66 JComboBox jcombo = null; 67 JLabel lEditor = null; 68 JPanel cEditor = null; 69 70 cEditor = new JPanel (); 71 lEditor = new JLabel ("Column Name"); 72 jcombo = new JComboBox (getTags()); 73 jcombo.addActionListener(this); 74 75 cEditor.setLayout(new BorderLayout ()); 76 cEditor.add(jcombo, BorderLayout.NORTH); 78 79 return cEditor; 80 } 81 82 public void actionPerformed(java.awt.event.ActionEvent e) { 83 this.setAsText((String )(((JComboBox )e.getSource()).getSelectedItem())); 84 } 85 86 } 87 | Popular Tags |