by Dinesh Thakur

 

import java.awt.BorderLayout;

import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
class JavaExampleColorPanel extends JFrame
  {
   JTextArea TxtArea;
   JavaExampleColorPanel(String TTL)
     {
       setTitle(TTL);
       setSize(550,300);
       setLayout(new FlowLayout());
       setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       Container Cntnr=getContentPane();
       Cntnr.setLayout(new BorderLayout());
       JButton BtnClr=new JButton(new Colorchooser("",new ImageIcon("java.png")));
       BtnClr.setBackground(Color.GRAY);
       JPanel Pnl=new JPanel(new FlowLayout(FlowLayout.LEFT));
       Pnl.add(BtnClr);
       Cntnr.add(Pnl,BorderLayout.NORTH);
       TxtArea=new JTextArea(10,30);
       TxtArea.setLineWrap(true);
       JScrollPane ScrlPn=new JScrollPane(TxtArea);
       Cntnr.add(ScrlPn,BorderLayout.CENTER);
       setVisible(true);
     }
       class Colorchooser extends AbstractAction
        {
             Colorchooser(String Strng,Icon Icn)
            {
                super(Strng,Icn); 
            }
                public void actionPerformed(ActionEvent ee)
              {
                      Color Clr=JColorChooser.showDialog(null, "Pick Color", Color.BLACK);
                      TxtArea.setForeground(Clr);
                  }
        }
                  public static void main(String[] aa)
                 {
                        new JavaExampleColorPanel("Color Chooser");
                     }
  }

JColorChooser Panel Java Example