JFileChooser is compound JComponent, you can extract JButtons
, JToggleButtons
and JScrollPane with JViewPort that contains JList, please download Darryl’s Swing Utils , read descriptions, then run (Darryl’s) code, result is selection for JList or JTable (I voting for that)
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.*;
import javax.swing.plaf.metal.MetalButtonUI;
public class CrazyFileChooser {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new CrazyFileChooser().makeUI();
}
});
}
public void makeUI() {
JFileChooser chooser = new JFileChooser();
for (AbstractButton button : SwingUtils.getDescendantsOfType(AbstractButton.class, chooser)) {
button.setUI(new XORButtonUI());
}
for (JList list : SwingUtils.getDescendantsOfType(JList.class, chooser)) {
list.setBackground(Color.PINK);
}
chooser.showOpenDialog(null);
}
}
class XORButtonUI extends MetalButtonUI {
@Override
public void paint(Graphics g, JComponent c) {
g.setXORMode(Color.YELLOW);
super.paint(g, c);
}
}