TechArena Community

TechArena Community (http://forums.techarena.in/)
-   Software Development (http://forums.techarena.in/software-development/)
-   -   Java Color Choosers (http://forums.techarena.in/software-development/1177624.htm)

Ebadaah 11-05-2009 08:54 AM

Java Color Choosers
 
hello friends,

I want to know what do you mean by the component called color choosers in Java ? and how do I use this component in my program ? Can anyone provide the information regarding this.....

Katty 11-05-2009 09:05 AM

Re: Java Color Choosers
 
A color chooser is a component that you can place anywhere within your program GUI. The color chooser consists of everything within the box labeled Choose Text Color.
This is how a standard color chooser looks like in Java.


It contains two parts - (i) a tabbed pane and (ii) a preview panel.
(i) In the tabbed pane, the three tabs select chooser panels.
(ii) The preview panel below the tabbed pane displays the currently selected color.

Use the JColorChooser class to provide users with a palette of colors to choose from. The JColorChooser API also makes it easy to bring up a dialog (modal or not) that contains a color chooser.

Katty 11-05-2009 09:11 AM

Re: Java Color Choosers
 
An example code that creates a JColorChooser instance and adds it to a container:

public class ColorChooserDemo extends JPanel ... {
public ColorChooserDemo()
{
super(new BorderLayout());
banner = new JLabel("Welcome to the Tutorial Zone!",
JLabel.CENTER);
banner.setForeground(Color.yellow);
. . .
tcc = new JColorChooser(banner.getForeground());
. . .
add(tcc, BorderLayout.PAGE_END);
}


For the detailed code - click here


All times are GMT +5.5. The time now is 01:38 AM.