https://github.com/teerjk/VarSifter
Tip revision: 7e57e5857b08f5253f28e96477fc211f67a0ffea authored by Jamie K. Teer on 27 April 2020, 14:42:41 UTC
-Documentation updates to point to github.
-Documentation updates to point to github.
Tip revision: 7e57e58
JRadioButtonRenderer.java
import javax.swing.*;
import javax.swing.table.*;
import java.awt.Component;
/**
* Renderer for the displaying of JRadioButtones in a table
*/
public class JRadioButtonRenderer extends JRadioButton implements TableCellRenderer {
public JRadioButtonRenderer() {
super();
setHorizontalAlignment(SwingConstants.CENTER);
}
@Override
public Component getTableCellRendererComponent(JTable t, Object inRb, boolean isSelected, boolean hasFocus,
int row, int col) {
JRadioButton rb = (JRadioButton)inRb;
if (isSelected) {
setForeground(t.getSelectionForeground());
setBackground(t.getSelectionBackground());
}
else {
setForeground(t.getForeground());
setBackground(t.getBackground());
}
setEnabled( rb.isEnabled() );
setSelected( rb.isSelected() );
return this;
}
}