set and disable icons of JToggleButton

1) for JToggleButton is better to implement ItemListener 2) here is SSCCE import java.awt.*; import java.awt.event.*; import javax.swing.*; public class ButtonsIcon extends JFrame { private static final long serialVersionUID = 1L; private Icon errorIcon = UIManager.getIcon(“OptionPane.errorIcon”); private Icon infoIcon = UIManager.getIcon(“OptionPane.informationIcon”); private Icon warnIcon = UIManager.getIcon(“OptionPane.warningIcon”); public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { … Read more

How can I put a control in the JTableHeader of a JTable?

The article How to Use Tables: Using Custom Renderers offers TableSorter as an example of how to detect mouse events on a column header. Using a similar approach, SelectAllHeader extends JToggleButton and implements TableCellRenderer in the example below to achieve a similar effect. A TableModelListener is used to condition the toggle button when all the … Read more