Forcing the JColorChooser to display only the RGB tab

Get the panels through the method getChooserPanels and remove the ones that
area not DefaultRGBChooserPanels.

Main.java:

import javax.swing.colorchooser.*;
import javax.swing.event.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
 
public class Main extends JFrame {
   public Main() {
      super("JColorChooser Demonstration");
   
      getContentPane().setLayout(new FlowLayout()); 
      JColorChooser colorChooser = new JColorChooser(); 
 
      AbstractColorChooserPanel[] panels = colorChooser.getChooserPanels(); 
      for (int i=0; i<panels.length; i++) {
         if (panels[i].toString().indexOf("DefaultRGBChooserPanel") == -1) {
            colorChooser.removeChooserPanel(panels[i]);
         }
      }
 
      getContentPane().add(colorChooser); 
  
      addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
            System.exit(0);
         }
      });
   }
 
   public static void main(String[] args) {
      Main main = new Main();
      main.pack();
      main.setVisible(true);
   }
}