Codota Logo
TristateCheckBox
Code IndexAdd Codota to your IDE (free)

How to use
TristateCheckBox
in
com.jidesoft.swing

Best Java code snippets using com.jidesoft.swing.TristateCheckBox (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Gson g =
  • Codota Iconnew Gson()
  • Codota IconGsonBuilder gsonBuilder;gsonBuilder.create()
  • Codota Iconnew GsonBuilder().create()
  • Smart code suggestions by Codota
}
origin: com.jidesoft/jide-oss

@Override
protected void init(String text, Icon icon) {
  model = createButtonModel();
  setModel(model);
  addActionListener(this);
  super.init(text, icon);
}
origin: com.jidesoft/jide-oss

@Override
public void actionPerformed(ActionEvent e) {
  stateUpdated(getState());
}
origin: com.jidesoft/jide-oss

@Override
public void setSelected(boolean b) {
  if (b) {
    setState(STATE_SELECTED);
  }
  else {
    setState(STATE_UNSELECTED);
  }
}
origin: com.jidesoft/jide-oss

@Override
public void updateUI() {
  super.updateUI();
  if (isMixed()) {
    adjustMixedIcon();
  }
  else {
    restoreMixedIcon();
  }
}
origin: senbox-org/snap-desktop

final ImageIcon shapeIcon = SpectrumShapeProvider.getShapeIcon(spectrum.getSymbolIndex());
spectraPanel.add(collapseButton);
final TristateCheckBox tristateCheckBox = new TristateCheckBox();
tristateCheckBox.setState(selectionAdmin.getState(index));
tristateCheckBox.addActionListener(new TristateCheckboxListener(index));
tristateCheckBoxes[index] = tristateCheckBox;
spectraPanel.add(tristateCheckBox);
origin: com.jidesoft/jide-oss

  /**
   * This method is called when the selection state changes.
   *
   * @param state the new selection state.
   */
  protected void stateUpdated(int state) {
    if (state == STATE_MIXED) {
      adjustMixedIcon();
      Object cp = UIDefaultsLookup.get("TristateCheckBox.setMixed.clientProperty");
      if (cp != null) {
        putClientProperty(((Object[]) cp)[0], ((Object[]) cp)[1]); // for Aqua L&F
      }
      String name = UIDefaultsLookup.getString("TristateCheckBox.setMixed.componentName");
      if (name != null) {
        setName(name); // for Synthetica
      }
    }
    else {
      restoreMixedIcon();
      Object cp = UIDefaultsLookup.get("TristateCheckBox.clearMixed.clientProperty");
      if (cp != null) {
        putClientProperty(((Object[]) cp)[0], ((Object[]) cp)[1]); // for Aqua L&F
      }
      String name = UIDefaultsLookup.getString("TristateCheckBox.clearMixed.componentName");
      if (name != null) {
        setName(name); // for Synthetica
      }
    }
  }
}
origin: com.jidesoft/jide-oss

private void validateCheckBox() {
  if (_checkBox == null || _checkBoxIcon != UIManager.getDefaults().getIcon("CheckBox.icon")) {
    _checkBox = new TristateCheckBox();
    _checkBox.setOpaque(false);
    _checkBoxIcon = UIManager.getDefaults().getIcon("CheckBox.icon");
    _uncheckImage = null;
    _checkedImage = null;
    _mixedImage = null;
  }
}
origin: senbox-org/snap-desktop

  @Override
  public void actionPerformed(ActionEvent e) {
    if (!selectionChangeLock) {
      selectionChangeLock = true;
      selectionAdmin.updateSpectrumSelectionState(index, tristateCheckBoxes[index].getState());
      tristateCheckBoxes[index].setState(selectionAdmin.getState(index));
      updateBandsTable(index);
      spectra[index].setSelected(selectionAdmin.isSpectrumSelected(index));
      selectionChangeLock = false;
    }
  }
}
origin: com.jidesoft/jide-oss

@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
  validateCheckBox();
  if (_uncheckImage == null) {
    GraphicsConfiguration graphicsConfiguration = ((Graphics2D) g).getDeviceConfiguration();
    _uncheckImage = graphicsConfiguration.createCompatibleImage(getIconWidth(), getIconHeight(), Transparency.TRANSLUCENT);
    _checkBox.setState(TristateCheckBox.STATE_UNSELECTED);
    _checkBox.setBounds(0, 0, getIconWidth(), getIconHeight());
    _checkBox.paint(_uncheckImage.getGraphics());
    _checkedImage = graphicsConfiguration.createCompatibleImage(getIconWidth(), getIconHeight(), Transparency.TRANSLUCENT);
    _checkBox.setState(TristateCheckBox.STATE_SELECTED);
    _checkBox.setBounds(0, 0, getIconWidth(), getIconHeight());
    _checkBox.paint(_checkedImage.getGraphics());
    _mixedImage = graphicsConfiguration.createCompatibleImage(getIconWidth(), getIconHeight(), Transparency.TRANSLUCENT);
    _checkBox.setState(TristateCheckBox.STATE_MIXED);
    _checkBox.setBounds(0, 0, getIconWidth(), getIconHeight());
    _checkBox.paint(_mixedImage.getGraphics());
  }
  if (getState() == TristateCheckBox.STATE_SELECTED) {
    g.drawImage(_checkedImage, x, y, null);
  }
  else if (getState() == TristateCheckBox.STATE_UNSELECTED) {
    g.drawImage(_uncheckImage, x, y, null);
  }
  else if (getState() == TristateCheckBox.STATE_MIXED) {
    g.drawImage(_mixedImage, x, y, null);
  }
}
origin: stackoverflow.com

myCheckBox = new TristateCheckBox();
myCheckBox.setText("123123");
add(myCheckBox);
myCheckBox.setHalfSelected(true);
origin: com.jidesoft/jide-oss

/**
 * Checks if the check box is in mixed selection state.
 *
 * @return true or false.
 */
public boolean isMixed() {
  return getState() == STATE_MIXED;
}
origin: com.jidesoft/jide-oss

public CheckBoxTreeCellRenderer(TreeCellRenderer renderer, TristateCheckBox checkBox) {
  _protoType = new TristateCheckBox();
  if (checkBox == null) {
    _checkBox = createCheckBox();
  }
  else {
    _checkBox = checkBox;
  }
  _emptyBox = (JComponent) Box.createHorizontalStrut(_protoType.getPreferredSize().width);
  setLayout(new BorderLayout(0, 0));
  setOpaque(false);
  _actualTreeRenderer = renderer;
}
origin: com.jidesoft/jide-oss

@Override
public int getIconWidth() {
  validateCheckBox();
  return _checkBox.getPreferredSize().width;
}
origin: com.jidesoft/jide-oss

@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);
}
origin: com.jidesoft/jide-oss

  @Override
  public String getToolTipText(MouseEvent event) {
    if (_actualTreeRenderer instanceof JComponent) {
      Point p = event.getPoint();
      p.translate(-_checkBox.getWidth(), 0);
      MouseEvent newEvent = new MouseEvent(((JComponent) _actualTreeRenderer), event.getID(),
          event.getWhen(),
          event.getModifiers(),
          p.x, p.y, event.getClickCount(),
          event.isPopupTrigger());

      String tip = ((JComponent) _actualTreeRenderer).getToolTipText(
          newEvent);

      if (tip != null) {
        return tip;
      }
    }
    return super.getToolTipText(event);
  }
}
origin: com.jidesoft/jide-oss

@Override
public int getIconHeight() {
  validateCheckBox();
  return _checkBox.getPreferredSize().height;
}
origin: com.jidesoft/jide-oss

if (c instanceof TristateCheckBox && ((TristateCheckBox) c).getModel() instanceof TristateButtonModel && ((TristateButtonModel) ((TristateCheckBox) c).getModel()).isMixed()) {
  drawSquare(c, g, x, y);
origin: com.jidesoft/jide-oss

/**
 * Sets the check box to mixed selection state.
 *
 * @param b true or false. True means mixed state. False means unselected state.
 */
public void setMixed(boolean b) {
  if (b) {
    setState(STATE_MIXED);
  }
  else {
    setState(STATE_UNSELECTED);
  }
}
origin: com.jidesoft/jide-oss

/**
 * Updates the check box state based on the selection in the selection model. By default, we check if the path is
 * selected. If yes, we mark the check box as TristateCheckBox.SELECTED. If not, we will check if the path is
 * partially selected, if yes, we set the check box as null or TristateCheckBox.DONT_CARE to indicate the path is
 * partially selected. Otherwise, we set it to TristateCheckBox.NOT_SELECTED.
 *
 * @param checkBox       the TristateCheckBox for the particular tree path.
 * @param path           the tree path.
 * @param selectionModel the CheckBoxTreeSelectionModel.
 */
protected void updateCheckBoxState(TristateCheckBox checkBox, TreePath path, CheckBoxTreeSelectionModel selectionModel) {
  if (selectionModel.isPathSelected(path, selectionModel.isDigIn()))
    checkBox.setState(TristateCheckBox.STATE_SELECTED);
  else
    checkBox.setState(selectionModel.isDigIn() && selectionModel.isPartiallySelected(path) ? TristateCheckBox.STATE_MIXED : TristateCheckBox.STATE_UNSELECTED);
}
origin: senbox-org/snap-desktop

selectionAdmin.setBandSelected(index, bandRow, selected);
selectionAdmin.updateSpectrumSelectionState(index, selectionAdmin.getState(index));
tristateCheckBoxes[index].setState(selectionAdmin.getState(index));
spectrum1.setSelected(selectionAdmin.isSpectrumSelected(index));
selectionChangeLock = false;
com.jidesoft.swingTristateCheckBox

Javadoc

TristateCheckBox is a check box with three states - selected, unselected and mixed (a.k.a partial selected state). Internally it uses a new class called TristateButtonModel to store the 3rd mixed state information.

The mixed state uses a different check icon. Instead of a checked sign in the selected state as in a regular check box, we use a square sign to indicate the mixed state. On different L&Fs, it might look different. TristateCheckBox supports most of the standard L&Fs such as Windows L&F, Metal L&F, Motif L&F, Nimbus L&F, Aqua L&F etc. For most L&Fs, we use a new UIDefault "TristateCheckBox.icon" to paint in three different states. However for Aqua L&F, we actually leveraged a client property provided by Apple to display the icon for the mixed state (refer to Radar #8930094 at http://developer.apple.com/library/mac/#releasenotes/Java/JavaSnowLeopardUpdate4LeopardUpdate9RN/ResolvedIssues/ResolvedIssues.html). To make it extensible for other L&Fs who might provide a built-in mixed state for check box, we support two types of customizations.

 
  • using client property as Aqua. You can define your own client properties and use UIDefaults to tell us how to set it. For example:
  • "TristateCheckBox.icon", null, "TristateCheckBox.setMixed.clientProperty", new Object[]{"JButton.selectedState", "indeterminate"}, "TristateCheckBox.clearMixed.clientProperty", new Object[]{"JButton.selectedState", null},
using component name. Some Synth-based L&Fs use component name to define style. If so, you can use the following two UIDefaults. For example: "TristateCheckBox.setMixed.componentName", "HalfSelected", "TristateCheckBox.clearMixed.componentName", "",
The correct listener for state change is ActionListener. It will be fired when the state is changed. The ItemListener is only fired when changing from selected state to unselected state or vice versa. Only ActionListener will be fired for all three states.

Most used methods

  • <init>
  • addActionListener
  • getState
    Gets the selection state. It could be one of the three states as defined - #STATE_SELECTED, #STATE_U
  • setState
    Sets the selection state. It could be one of the three states as defined - #STATE_SELECTED, #STATE_U
  • adjustMixedIcon
  • createButtonModel
    Creates the button model. In this case, it is always a TristateButtonModel.
  • getModel
  • getPreferredSize
  • getWidth
  • isMixed
    Checks if the check box is in mixed selection state.
  • paint
  • putClientProperty
  • paint,
  • putClientProperty,
  • restoreMixedIcon,
  • setBackground,
  • setBounds,
  • setEnabled,
  • setFont,
  • setForeground,
  • setHalfSelected,
  • setIcon

Popular in Java

  • Making http requests using okhttp
  • getExternalFilesDir (Context)
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • runOnUiThread (Activity)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • PrintWriter (java.io)
    Prints formatted representations of objects to a text-output stream. This class implements all of th
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Iterator (java.util)
    An iterator over a collection. Iterator takes the place of Enumeration in the Java Collections Frame
  • JLabel (javax.swing)
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now