package com.vci.client.ui.swing.components; import java.awt.Color; import java.awt.Graphics; import javax.swing.Action; import javax.swing.Icon; import javax.swing.JCheckBox; 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 VCIJCheckBox extends JCheckBox { /** * */ private static final long serialVersionUID = -8258422493522231275L; public VCIJCheckBox() { this(null, null, false); } public VCIJCheckBox(Icon icon) { this(null, icon, false); } public VCIJCheckBox(String text) { this(text, null, false); } public VCIJCheckBox(Action a) { this(); if(a != null) setAction(a); } public VCIJCheckBox(Icon icon, boolean selected) { this(null, icon, selected); } public VCIJCheckBox(String text, boolean selected) { this(text, null, selected); } public VCIJCheckBox(String text, Icon icon) { this(text, icon, false); } public VCIJCheckBox(String text, Icon icon, boolean selected) { super(text, icon, selected); customConstructor(); } private void customConstructor(){ setFont(VCISwingUtil.FONT_DEFAULT); } @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; } }