Ejemplo n.º 1
0
  @Override
  public void paintIcon(Component c, Graphics g, int x, int y) {
    Icon icon = (Icon) _originalIcon.createValue(UIManager.getDefaults());
    if (isSynthIcon(icon)) {
      int state = getComponentState((JComponent) c);
      if (c instanceof TristateCheckBox
          && ((TristateCheckBox) c).getModel() instanceof TristateButtonModel
          && ((TristateButtonModel) ((TristateCheckBox) c).getModel()).isMixed())
        state &= ~SynthConstants.SELECTED;
      SynthContext context =
          new SynthContext(
              (JComponent) c,
              Region.CHECK_BOX,
              SynthLookAndFeel.getStyle((JComponent) c, Region.CHECK_BOX),
              state);
      final int w = ((SynthIcon) icon).getIconWidth(context);
      final int h = ((SynthIcon) icon).getIconHeight(context);
      ((SynthIcon) icon).paintIcon(context, g, x, y, w, h);
    } else {
      if (c instanceof TristateCheckBox
          && ((TristateCheckBox) c).getModel() instanceof TristateButtonModel
          && ((TristateButtonModel) ((TristateCheckBox) c).getModel()).isMixed()) {
        ((TristateButtonModel) ((TristateCheckBox) c).getModel()).internalSetSelected(false);
      }
      icon.paintIcon(c, g, x, y);
      if (c instanceof TristateCheckBox
          && ((TristateCheckBox) c).getModel() instanceof TristateButtonModel
          && ((TristateButtonModel) ((TristateCheckBox) c).getModel()).isMixed()) {
        ((TristateButtonModel) ((TristateCheckBox) c).getModel()).internalSetSelected(true);
      }
    }

    g.setColor(UIManager.getColor("CheckBox.foreground"));
    if (c instanceof TristateCheckBox
        && ((TristateCheckBox) c).getModel() instanceof TristateButtonModel
        && ((TristateButtonModel) ((TristateCheckBox) c).getModel()).isMixed())
      drawSquare(c, g, x, y);
  }
Ejemplo n.º 2
0
 @Override
 public int getIconHeight() {
   Icon icon = (Icon) _originalIcon.createValue(UIManager.getDefaults());
   return icon.getIconHeight();
 }