1 33 34 package com.nqadmin.swingSet.formatting; 35 36 import java.awt.Color ; 37 import javax.swing.ComboBoxEditor ; 38 import javax.swing.JComboBox ; 39 import javax.swing.ListCellRenderer ; 40 41 45 public class SSFormattedTextFieldCombo extends JComboBox implements ListCellRenderer , ComboBoxEditor { 46 47 private SSFormattedTextField editor; 48 private SSFormattedTextField renderer; 49 50 51 public SSFormattedTextFieldCombo() { 52 53 editor = new SSFormattedTextField(); 54 renderer = editor; 55 56 this.setRenderer(this); 57 this.setEditor(this); 58 59 } 60 61 67 68 public void setItem(Object anObject) { 69 editor.setValue(anObject); 70 } 71 72 public void selectAll() { 73 74 } 75 76 public Object getItem() { 77 return editor.getValue(); 78 } 79 80 public java.awt.Component getEditorComponent() { 81 return editor; 82 } 83 84 89 public java.awt.Component getListCellRendererComponent(javax.swing.JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { 90 91 if (isSelected == false) { 92 renderer.setBackground(Color.WHITE); 93 renderer.setForeground(Color.BLACK); 94 renderer.setBorder(null); 95 } 96 else { 97 renderer.setBackground(Color.BLUE); 98 renderer.setForeground(Color.WHITE); 99 renderer.setBorder(null); 100 } 101 102 if (cellHasFocus){ 103 104 } 105 else { 106 107 } 108 renderer.setValue(value); 109 return renderer; 110 111 } 112 113 } 114 | Popular Tags |