KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nqadmin > swingSet > formatting > SSFormattedTextFieldColumnNamePropertyEditor


1 /*
2  * SSFormattedTextFieldColumnNamePropertyEditor.java
3  *
4  * Created on 19 de enero de 2005, 19:16
5  */

6
7 package com.nqadmin.swingSet.formatting;
8
9 import java.awt.BorderLayout JavaDoc;
10 import java.awt.event.ActionListener JavaDoc;
11 import java.beans.*;
12 import javax.swing.JComboBox JavaDoc;
13 import javax.swing.JLabel JavaDoc;
14 import javax.swing.JPanel JavaDoc;
15
16 /**
17  * @author dags
18  */

19 public class SSFormattedTextFieldColumnNamePropertyEditor extends PropertyEditorSupport implements ActionListener JavaDoc {
20     
21     private String JavaDoc cn = "<none>";
22     
23     public SSFormattedTextFieldColumnNamePropertyEditor() {
24         super();
25         cn = new String JavaDoc("<none>");
26     }
27     
28     public boolean supportsCustomEditor() {
29         return true;
30     }
31     
32     public String JavaDoc[] getTags() {
33         
34         String JavaDoc[] 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 JavaDoc sValue) {
45         cn = sValue;
46         setValue(cn);
47         firePropertyChange();
48     }
49     
50     public String JavaDoc getAsText() {
51         return cn;
52     }
53     
54     public String JavaDoc getJavaInitializationString() {
55         String JavaDoc 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 JavaDoc getCustomEditor() {
66         JComboBox JavaDoc jcombo = null;
67         JLabel JavaDoc lEditor = null;
68         JPanel JavaDoc cEditor = null;
69         
70         cEditor = new JPanel JavaDoc();
71         lEditor = new JLabel JavaDoc("Column Name");
72         jcombo = new JComboBox JavaDoc(getTags());
73         jcombo.addActionListener(this);
74         
75         cEditor.setLayout(new BorderLayout JavaDoc());
76 // cEditor.add(lEditor, BorderLayout.NORTH);
77
cEditor.add(jcombo, BorderLayout.NORTH);
78         
79         return cEditor;
80     }
81     
82     public void actionPerformed(java.awt.event.ActionEvent JavaDoc e) {
83         this.setAsText((String JavaDoc)(((JComboBox JavaDoc)e.getSource()).getSelectedItem()));
84     }
85     
86 }
87
Popular Tags