How To Remove Recent Of Swatch Tab In JColorChooser

There is no direct way to do this based on the JColorChooser API so we will have to do it old style.

JColorChooser cc = new JColorChooser();
AbstractColorChooserPanel colorPanel = cc.getChooserPanels()[0];
JPanel p = (JPanel) colorPanel.getComponent(0);
p.remove(2);
p.remove(1);

The getComponent(0) refers to the first tab of the JColorChooser, in this case the swatch tab. The remove() method is called twice on index number 1 and 2 because 1 is the JLabel while 2 is the recent color history.

That’s it. That should give you a swatch content only tab.

Related Posts Plugin for WordPress, Blogger...

Post a Comment

Anti-Spam Protection by WP-SpamFree

Spam protection by WP Captcha-Free