@Override
    protected void buildChooser() {
      final JPanel colorList = new JPanel();

      colorList.setLayout(new GridLayout(m_recentColors.length, 1, 1, 1));

      for (final Color col : m_recentColors) {
        final ColorPanel cp = new ColorPanel(col, false, true);
        cp.addMouseListener(
            new MouseAdapter() {
              @Override
              public void mouseClicked(final MouseEvent e) {
                if (e.getButton() != MouseEvent.BUTTON1) {
                  return;
                }
                getColorSelectionModel().setSelectedColor(col);
              }
            });
        cp.setPreferredSize(new Dimension(200, 25));

        final JPanel p = new JPanel();
        p.setBorder(new EmptyBorder(1, 1, 1, 1));
        p.add(cp, BorderLayout.PAGE_START);

        colorList.add(cp);
      }

      final GridBagConstraints c = new GridBagConstraints();
      c.gridx = 0;
      c.gridy = 0;
      c.anchor = GridBagConstraints.FIRST_LINE_START;
      c.weightx = 1;
      c.fill = GridBagConstraints.HORIZONTAL;

      final JPanel innerPanel = new JPanel(new GridBagLayout());
      innerPanel.add(colorList, c);

      final JPanel outerPanel = new JPanel(new BorderLayout());
      outerPanel.add(innerPanel, BorderLayout.NORTH);

      final JScrollPane sp = new JScrollPane(outerPanel);
      sp.setBorder(null);
      sp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
      sp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
      add(sp, BorderLayout.CENTER);
    }
@author cblichmann@google.com (Christian Blichmann)
java/zylib/src/main/java/com/google/security/zynamics/zylib/gui/CColorChooser.java