本文整理汇总了Java中javax.swing.JCheckBox.setIcon方法的典型用法代码示例。如果您正苦于以下问题:Java JCheckBox.setIcon方法的具体用法?Java JCheckBox.setIcon怎么用?Java JCheckBox.setIcon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JCheckBox
的用法示例。
在下文中一共展示了JCheckBox.setIcon方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initLayerControl
import javax.swing.JCheckBox; //导入方法依赖的package包/类
private void initLayerControl() {
Map map = EditorScreen.instance().getMapComponent().getMaps().get(mapList.getSelectedIndex());
layerModel.clear();
for (IMapObjectLayer layer : map.getMapObjectLayers()) {
JCheckBox newBox = new JCheckBox(layer.getName() + " (" + layer.getMapObjects().size() + ")");
if (layer.getColor() != null) {
BufferedImage img = ImageProcessing.getCompatibleImage(10, 10);
Graphics2D g = (Graphics2D) img.getGraphics();
g.setColor(layer.getColor());
g.fillRect(0, 0, 9, 9);
g.setColor(Color.BLACK);
g.drawRect(0, 0, 9, 9);
g.dispose();
newBox.setIcon(new ImageIcon(img));
}
newBox.setSelected(true);
layerModel.addElement(newBox);
}
int start = 0;
int end = mapList.getModel().getSize() - 1;
if (end >= 0) {
listObjectLayers.setSelectionInterval(start, end);
}
}
示例2: createCollapseControl
import javax.swing.JCheckBox; //导入方法依赖的package包/类
protected Component createCollapseControl(String title, String tooltip) {
Box box = Box.createHorizontalBox();
expand = new JCheckBox(title);
expand.setBorder(new EmptyBorder(0, 4, 0, 0));
expand.setToolTipText(tooltip);
expand.setHorizontalTextPosition(JCheckBox.RIGHT);
expand.setIcon(new ArrowIcon(ArrowIcon.EAST));
setCollapsedIcon(new ArrowIcon(ArrowIcon.EAST));
setExpandedIcon(new ArrowIcon(ArrowIcon.SOUTH));
expand.setSelected(isExpanded());
expand.setFocusPainted(false);
expand.addChangeListener(new CollapseListener());
box.add(expand);
return box;
}
示例3: setupThumbClose
import javax.swing.JCheckBox; //导入方法依赖的package包/类
/**
* create returns the thumb close component
*
* @param p
* @return
*/
private JComponent setupThumbClose(final JPanel p) {
JCheckBox cb = new JCheckBox();
cb.setIcon(close);
cb.setSelectedIcon(closesel);
cb.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
removeThumbPanel(p);
}
});
cb.setPreferredSize(CL_SIZE);
cb.setMaximumSize(CL_SIZE);
return cb;
}