package com.vci.client.ui.swing.components; import java.awt.Color; import java.awt.Graphics; import java.util.Vector; import javax.swing.ComboBoxModel; import javax.swing.DefaultComboBoxModel; import javax.swing.JComboBox; import com.vci.client.ui.swing.VCISwingUtil; /** * *

Title:

*

Description:

*

Copyright: Copyright (c) 2012

*

Company: VCI

* @author xchao * @time 2012-5-10 * @version 1.0 */ public class VCIJComboBox extends JComboBox { /** * */ private static final long serialVersionUID = -2532699004993221738L; public VCIJComboBox() { this(new DefaultComboBoxModel()); } public VCIJComboBox(Object[] items) { this(new DefaultComboBoxModel(items)); } public VCIJComboBox(Vector items) { this(new DefaultComboBoxModel(items)); } public VCIJComboBox(ComboBoxModel aModel) { super(aModel); customConstructor(); } private void customConstructor(){ setFont(VCISwingUtil.FONT_DEFAULT); this.setSize(100, 23); } @Override public void paint(Graphics g){ super.paint(g); if(isRequired()) { drawRequiredFlag(g); } } private void drawRequiredFlag(Graphics g){ int x = getWidth() - 9; int y = 1; g.setColor(Color.RED); g.fillArc(x, y, 7, 7, 0, 360); // int x = getWidth() - 10; // int y = 10; // g.setColor(Color.RED); // g.drawString("*", x, y); } private boolean required = false; public boolean isRequired() { return required; } public void setRequired(boolean required) { this.required = required; } private Object obj = null; public Object getObj() { return obj; } public void setObj(Object obj) { this.obj = obj; } public void firePropertyChangeV2(String propertyName, Object oldValue, Object newValue) { super.firePropertyChange(propertyName, oldValue, newValue); } }