javax.swing.JCheckBox.setSelectedIcon()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(10.7k)|赞(0)|评价(0)|浏览(159)

本文整理了Java中javax.swing.JCheckBox.setSelectedIcon()方法的一些代码示例,展示了JCheckBox.setSelectedIcon()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JCheckBox.setSelectedIcon()方法的具体详情如下:
包路径:javax.swing.JCheckBox
类名称:JCheckBox
方法名:setSelectedIcon

JCheckBox.setSelectedIcon介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

JCheckBox cb = new JCheckBox(createImageIcon("off-image.gif", "Click To Turn On"));
cb.setSelectedIcon(createImageIcon("on-image.gif", "Click To Turn Off"));

代码示例来源:origin: stackoverflow.com

public void setIcons(Jtable table, int column, Icon icon, Icon selectedIcon) {
  JCheckBox cellRenderer = (JCheckBox) table.getCellRenderer(0, column);
  cellRenderer.setSelectedIcon(selectedIcon);
  cellRenderer.setIcon(icon);

  DefaultCellEditor cellEditor = (DefaultCellEditor) table.getCellEditor(0, column);
  JCheckBox editorComponent = (JCheckBox) cellEditor.getComponent();
  editorComponent.setSelectedIcon(selectedIcon);
  editorComponent.setIcon(icon);
}

代码示例来源:origin: lbalazscs/Pixelitor

private void initVisibilityControl(Layer layer) {
  visibilityCB = new JCheckBox(CLOSED_EYE_ICON);
  visibilityCB.setRolloverIcon(CLOSED_EYE_ICON);
  visibilityCB.setSelected(true);
  visibilityCB.setToolTipText("<html><b>Click</b> to hide/show this layer.");
  visibilityCB.setSelectedIcon(OPEN_EYE_ICON);
  add(visibilityCB, LayerButtonLayout.CHECKBOX);
  visibilityCB.addItemListener(e ->
      layer.setVisible(visibilityCB.isSelected(), true));
}

代码示例来源:origin: MrCrayfish/ModelCreator

public static JCheckBox createCheckBox(String text, String tooltip, boolean selected)
{
  JCheckBox checkBox = new JCheckBox(text);
  checkBox.setToolTipText(tooltip);
  checkBox.setSelected(selected);
  checkBox.setIcon(Icons.light_off);
  checkBox.setRolloverIcon(Icons.light_off);
  checkBox.setSelectedIcon(Icons.light_on);
  checkBox.setRolloverSelectedIcon(Icons.light_on);
  return checkBox;
}

代码示例来源:origin: stackoverflow.com

public class TestPane extends JPanel {

  public TestPane() {
    try {
      JCheckBox cb = new JCheckBox();
      cb.setSelectedIcon(new ImageIcon(ImageIO.read(...)));
      cb.setIcon(new ImageIcon(ImageIO.read(...)));
      cb.setBackground(Color.RED);
      cb.setOpaque(true);
      add(cb);
    } catch (IOException ex) {
      ex.printStackTrace();
    }
  }

}

代码示例来源:origin: stackoverflow.com

Icon normal = new ImageIcon(...);
Icon selected = new ImageIcon(...);
JTable table = new JTable(...);
table.setRowHeight(...);

TableCellRenderer renderer = table.getDefaultRenderer(Boolean.class);
JCheckBox checkBoxRenderer = (JCheckBox)renderer;
checkBoxRenderer.setIcon( normal );
checkBoxRenderer.setSelectedIcon( selected );

DefaultCellEditor editor = (DefaultCellEditor)table.getDefaultEditor(Boolean.class);
JCheckBox checkBoxEditor = (JCheckBox)editor.getComponent();
checkBoxEditor.setIcon( normal );
checkBoxEditor.setSelectedIcon( selected );

代码示例来源:origin: stackoverflow.com

boxFontMetrics.getHeight(), boxFontMetrics.getHeight(), Image.SCALE_SMOOTH
);
checkbox.setSelectedIcon(new ImageIcon(finalCheckedBoxImage));
checkbox.setSelected(false);
checkbox.setSelected(previousState);

代码示例来源:origin: org.rwshop/org.rwshop.swing.common

private static void makeCellCheckBox(JCheckBox cb, Icon icon, Icon selIcon, String tooltip){
  cb.setHorizontalAlignment(JCheckBox.CENTER);
  if(icon != null){
    cb.setIcon(icon);
  }
  if(selIcon != null){
    cb.setSelectedIcon(selIcon);
  }
  cb.setOpaque(true);
  cb.setToolTipText(tooltip);
}

代码示例来源:origin: igniterealtime/Spark

private JPanel createCheckBoxes() {
  JPanel panel = new JPanel();
  panel.setLayout(new GridBagLayout());
  panel.setBorder(BorderFactory.createTitledBorder(Res.getString("privacy.border.block")));
  _blockPIn = new JCheckBox(Res.getString("privacy.label.pin.desc"));
  _blockPIn.setIcon(SparkRes.getImageIcon("PRIVACY_PIN_ALLOW"));
  _blockPIn.setSelectedIcon(SparkRes.getImageIcon("PRIVACY_PIN_DENY"));
  _blockPIn.setRolloverEnabled(false);
  _blockPOout = new JCheckBox(Res.getString("privacy.label.pout.desc"));
  _blockPOout.setIcon(SparkRes.getImageIcon("PRIVACY_POUT_ALLOW"));
  _blockPOout.setSelectedIcon(SparkRes.getImageIcon("PRIVACY_POUT_DENY"));
  _blockPOout.setRolloverEnabled(false);
  _blockMsg = new JCheckBox(Res.getString("privacy.label.msg.desc"));
  _blockMsg.setSelectedIcon(SparkRes.getImageIcon("PRIVACY_MSG_DENY"));
  _blockMsg.setIcon(SparkRes.getImageIcon("PRIVACY_MSG_ALLOW"));
  _blockMsg.setRolloverEnabled(false);
  _blockIQ = new JCheckBox(Res.getString("privacy.label.iq.desc"));
  _blockIQ.setSelectedIcon(SparkRes.getImageIcon("PRIVACY_QUERY_DENY"));
  _blockIQ.setIcon(SparkRes.getImageIcon("PRIVACY_QUERY_ALLOW"));
  _blockIQ.setRolloverEnabled(false);
  panel.add(_blockPIn, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  panel.add(_blockPOout, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  panel.add(_blockMsg, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  panel.add(_blockIQ, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  return panel;
}

代码示例来源:origin: MegaMek/mekhq

private JCheckBox createOptionCheckBox(String text, Icon checkboxIcon, Icon checkboxSelectedIcon) {
  JCheckBox checkBox = new JCheckBox(text);
  checkBox.setOpaque(false);
  checkBox.setForeground(new Color(150, 220, 255));
  checkBox.setFocusable(false);
  checkBox.setFont(checkBox.getFont().deriveFont(Font.BOLD));
  checkBox.setPreferredSize(new Dimension(150, 20));
  checkBox.setIcon(checkboxIcon);
  checkBox.setSelectedIcon(checkboxSelectedIcon);
  checkBox.setSelected(false);
  checkBox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      repaint();
    }
  });
  return checkBox;
}

代码示例来源:origin: UNIVALI-LITE/Portugol-Studio

@Override
public void configurarCores() 
{        
  if(WeblafUtils.weblafEstaInstalado())
  {
    WeblafUtils.configuraWebLaf(seletorPlugin);
  }
  setBackground(ColorController.FUNDO_CLARO);
  labelPluginInstalado.setBackground(ColorController.PROGRESS_BAR);
  labelPluginInstalado.setForeground(ColorController.COR_LETRA);
  seletorPlugin.setSelectedIcon(IconFactory.createIcon(IconFactory.CAMINHO_ICONES_PEQUENOS, "selected.png"));
  seletorPlugin.setIcon(IconFactory.createIcon(IconFactory.CAMINHO_ICONES_PEQUENOS, "unselected.png"));
}

代码示例来源:origin: atarw/material-ui-swing

@Override
public void installUI (JComponent c) {
  super.installUI (c);
  JCheckBox checkBox = (JCheckBox) c;
  checkBox.setFont (UIManager.getFont ("CheckBox.font"));
  checkBox.setBackground (UIManager.getColor ("CheckBox.background"));
  checkBox.setForeground (UIManager.getColor ("CheckBox.foreground"));
  checkBox.setIcon (UIManager.getIcon ("CheckBox.icon"));
  checkBox.setSelectedIcon (UIManager.getIcon ("CheckBox.selectedIcon"));
}

代码示例来源:origin: UNIVALI-LITE/Portugol-Studio

public AbaGerenciadorBibliotecas(AbaCodigoFonte abaCodigoFonte) {
  super("Bibliotecas", IconFactory.createIcon(IconFactory.CAMINHO_ICONES_PEQUENOS, "biblioteca.png"), false);
  this.abaCodigoFonte = abaCodigoFonte;
  initComponents();
  
  List<String> libs = GerenciadorBibliotecas.getInstance().getBibliotecasDisponiveis();
  for (String lib : libs) {
    JCheckBox check = new JCheckBox(lib);
    check.setForeground(ColorController.COR_LETRA);
    check.setSelectedIcon(IconFactory.createIcon(IconFactory.CAMINHO_ICONES_PEQUENOS, "selected.png"));
    check.setIcon(IconFactory.createIcon(IconFactory.CAMINHO_ICONES_PEQUENOS, "unselected.png"));
    FabricaDicasInterface.criarTooltipEstatica(check, lib);     
    if(abaCodigoFonte.getPortugolDocumento().getCodigoFonte().contains("inclua biblioteca "+lib)){
      check.setSelected(true);
    }
    
    check.addItemListener(new ItemListener() {
      @Override
      public void itemStateChanged(ItemEvent ie) {
        if(ie.getStateChange() == ItemEvent.SELECTED){
          abaCodigoFonte.adicionarBiblioteca(((JCheckBox)ie.getItem()).getText());
        }else{
          abaCodigoFonte.removerBiblioteca(((JCheckBox)ie.getItem()).getText());
        }
      }
    });
    painelCheckBox.add(check);
  }
  configurarCores();
}

代码示例来源:origin: sc.fiji/TrakEM2_

this.c.addMouseListener(listener);
this.c.setIcon(INVISIBLE);
this.c.setSelectedIcon(VISIBLE);
this.c.setBackground(Color.white);
Dimension maxdim = new Dimension(26, 14);
this.c_locked.setSelectedIcon(LOCKED);
this.c_locked.setSelected(d.isLocked2());
this.c_locked.addMouseListener(listener);
this.c_linked.setSelectedIcon(LINKED);
this.c_linked.setSelected(d.isLinked());
this.c_linked.addMouseListener(listener);

代码示例来源:origin: org.codehaus.izpack/izpack-panel

CheckBoxRenderer()
{
  if (com.izforge.izpack.util.OsVersion.IS_UNIX && !com.izforge.izpack.util.OsVersion.IS_OSX)
  {
    checkbox.setIcon(new LFIndependentIcon());
    checkbox.setDisabledIcon(new LFIndependentIcon());
    checkbox.setSelectedIcon(new LFIndependentIcon());
    checkbox.setDisabledSelectedIcon(new LFIndependentIcon());
  }
  checkbox.setHorizontalAlignment(CENTER);
}

代码示例来源:origin: MrCrayfish/ModelCreator

checkBoxEnabled.setIcon(Icons.light_off);
checkBoxEnabled.setRolloverIcon(Icons.light_off);
checkBoxEnabled.setSelectedIcon(Icons.light_on);
checkBoxEnabled.setRolloverSelectedIcon(Icons.light_on);
checkBoxEnabled.addActionListener(e ->

代码示例来源:origin: UNIVALI-LITE/Portugol-Studio

WeblafUtils.configurarBotao(cancelarButton, ColorController.FUNDO_ESCURO, ColorController.COR_LETRA_TITULO, ColorController.FUNDO_CLARO, ColorController.COR_LETRA, 2, true);
marcarCheckBox.setSelectedIcon(IconFactory.createIcon(IconFactory.CAMINHO_ICONES_PEQUENOS, "selected.png"));
marcarCheckBox.setIcon(IconFactory.createIcon(IconFactory.CAMINHO_ICONES_PEQUENOS, "unselected.png"));
diferenciarCheckBox.setSelectedIcon(IconFactory.createIcon(IconFactory.CAMINHO_ICONES_PEQUENOS, "selected.png"));
diferenciarCheckBox.setIcon(IconFactory.createIcon(IconFactory.CAMINHO_ICONES_PEQUENOS, "unselected.png"));
palavraInteiraCheckBox.setSelectedIcon(IconFactory.createIcon(IconFactory.CAMINHO_ICONES_PEQUENOS, "selected.png"));
palavraInteiraCheckBox.setIcon(IconFactory.createIcon(IconFactory.CAMINHO_ICONES_PEQUENOS, "unselected.png"));
expressaoCheckBox.setSelectedIcon(IconFactory.createIcon(IconFactory.CAMINHO_ICONES_PEQUENOS, "selected.png"));
expressaoCheckBox.setIcon(IconFactory.createIcon(IconFactory.CAMINHO_ICONES_PEQUENOS, "unselected.png"));
avancarRadioButton.setSelectedIcon(IconFactory.createIcon(IconFactory.CAMINHO_ICONES_PEQUENOS, "selected_rounded.png"));

代码示例来源:origin: org.gdl-lang.gdl-tools/openehr-utils-gui-swing

((SelectableNode<?>) value).getIcon()});
leafRenderer.setSelectedIcon(selectedIcon);
leafRenderer.setDisabledSelectedIcon(unSelectedIcon);
if (node.isSelected()) {
Icon icon = ((SelectableNode<?>) value).getIcon();
leafRenderer.setIcon(icon);
leafRenderer.setSelectedIcon(icon);
leafRenderer.setDisabledSelectedIcon(icon);

相关文章

JCheckBox类方法