ColorChooser Sample 1 : Color Chooser « Swing JFC « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Class
8. Collections Data Structure
9. Data Type
10. Database SQL JDBC
11. Design Pattern
12. Development Class
13. EJB3
14. Email
15. Event
16. File Input Output
17. Game
18. Generics
19. GWT
20. Hibernate
21. I18N
22. J2EE
23. J2ME
24. JDK 6
25. JNDI LDAP
26. JPA
27. JSP
28. JSTL
29. Language Basics
30. Network Protocol
31. PDF RTF
32. Reflection
33. Regular Expressions
34. Scripting
35. Security
36. Servlets
37. Spring
38. Swing Components
39. Swing JFC
40. SWT JFace Eclipse
41. Threads
42. Tiny Application
43. Velocity
44. Web Services SOA
45. XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java » Swing JFC » Color ChooserScreenshots 
ColorChooser Sample 1
ColorChooser Sample 1
  
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JFrame;

public class ColorChooserSample {
  public static void main(String args[]) {
    JFrame f = new JFrame("JColorChooser Sample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container content = f.getContentPane();
    final JButton button = new JButton("Pick to Change Background");

    ActionListener actionListener = new ActionListener() {
      public void actionPerformed(ActionEvent actionEvent) {
        Color initialBackground = button.getBackground();
        Color background = JColorChooser.showDialog(null,
            "JColorChooser Sample", initialBackground);
        if (background != null) {
          button.setBackground(background);
        }
      }
    };
    button.addActionListener(actionListener);
    content.add(button, BorderLayout.CENTER);
    f.setSize(300200);
    f.setVisible(true);
  }
}

           
         
    
  
Related examples in the same category
1. JColorChooser dialog with a custom preview pane.JColorChooser dialog with a custom preview pane.
2. JColorChooser dialog with the custom GrayScalePanel picker tab.JColorChooser dialog with the custom GrayScalePanel picker tab.
3. A quick test of the JColorChooser dialogA quick test of the JColorChooser dialog
4. Color Chooser DemoColor Chooser Demo
5. System Color ChooserSystem Color Chooser
6. JColorChooser demoJColorChooser demo
7. ColorChooser Demo 2ColorChooser Demo 2
8. Swing ColorChooser DemoSwing ColorChooser Demo
9. Setting the Order of the Color Chooser Panel Tabs in a JColorChooser Dialog
10. Removing a Color Chooser Panel from a JColorChooser Dialog
11. Preview pane simply displays the currently selected color.
12. Retrieving the Color Chooser Panels in a JColorChooser Dialog
13. Customizing the Preview Panel of a JColorChooser Dialog
14. Getting and Setting the Selected Color in a JColorChooser Dialog
15. Creating a JColorChooser Dialog
16. Listening for Changes to the Selected Color in a JColorChooser Dialog
17. Listening for OK and Cancel Events in a JColorChooser Dialog
18. Removing the Preview Panel from a JColorChooser Dialog
19. Adding a Custom Color Chooser Panel to a JColorChooser Dialog
20. extends AbstractColorChooserPanelextends AbstractColorChooserPanel
21. Choose foreground or background color
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.