📄 xpcheckboxicon.java
字号:
// Beta
/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* XP Look and Feel *
* *
* (C) Copyright 2002, by Stefan Krause, Taufik Romdhane and Contributors *
* *
* *
* The XP Look and Feel started as as extension to the Metouia Look and Feel. *
* The original header of this file was: *
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Metouia Look And Feel: a free pluggable look and feel for java *
* http://mlf.sourceforge.net *
* (C) Copyright 2002, by Taoufik Romdhane and Contributors. *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. *
* *
* XPCheckBoxIcon.java *
* Original Author: Taoufik Romdhane *
* Contributor(s): Christian Walker *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
package com.stefankrause.xplookandfeel;
import java.awt.Component;
import java.awt.Graphics;
import javax.swing.AbstractButton;
import javax.swing.plaf.metal.MetalCheckBoxIcon;
import com.stefankrause.xplookandfeel.skin.Skin;
import com.stefankrause.xplookandfeel.skin.SkinToggleButtonIndexModel;
/**
* This class represents a check box icon.
*
* @author Taoufik Romdhane
*/
public class XPCheckBoxIcon extends MetalCheckBoxIcon {
protected static Skin skin;
private SkinToggleButtonIndexModel indexModel=new SkinToggleButtonIndexModel();
/**
* Draws the check box icon at the specified location.
*
* @param c The component to draw on.
* @param g The graphics context.
* @param x The x coordinate of the top left corner.
* @param y The y coordinate of the top left corner.
*/
protected int getControlSize() {
return getSkin().getHsize();
}
public void paintIcon(Component c, Graphics g, int x, int y) {
AbstractButton button = (AbstractButton) c;
indexModel.setButton(button);
int index=indexModel.getIndexForState();
getSkin().draw(g, index, x,y, getSkin().getHsize(),getSkin().getVsize());
}
public int getIconWidth() {
return getSkin().getHsize();
}
public int getIconHeight() {
return getSkin().getVsize();
}
public Skin getSkin() {
if (skin==null)
skin=new Skin("XPCheckbox.res", 8, 0);
return skin;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -