Source Code Cross Referenced for ColorChooserMainPanel.java in  » Swing-Library » substance-look-feel » contrib » ch » randelshofer » quaqua » colorchooser » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
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 Source Code / Java Documentation » Swing Library » substance look feel » contrib.ch.randelshofer.quaqua.colorchooser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)ColorChooserMainPanel.java  1.4  2005-12-18
003:         *
004:         * Copyright (c) 2005 Werner Randelshofer
005:         * Staldenmattweg 2, Immensee, CH-6405, Switzerland.
006:         * All rights reserved.
007:         *
008:         * This software is the confidential and proprietary information of
009:         * Werner Randelshofer. ("Confidential Information").  You shall not
010:         * disclose such Confidential Information and shall use it only in
011:         * accordance with the terms of the license agreement you entered into
012:         * with Werner Randelshofer.
013:         */
014:
015:        package contrib.ch.randelshofer.quaqua.colorchooser;
016:
017:        import java.awt.*;
018:        import java.awt.event.ItemEvent;
019:        import java.awt.event.ItemListener;
020:
021:        import javax.swing.*;
022:        import javax.swing.colorchooser.AbstractColorChooserPanel;
023:
024:        import contrib.ch.randelshofer.quaqua.util.Methods;
025:
026:        /**
027:         * The main panel of the color chooser UI.
028:         * 
029:         * @author Werner Randelshofer
030:         * @version 1.4 2005-12-18 ColorPicker added. <br>
031:         *          1.3 2005-09-05 Get font from UIManager. <br>
032:         *          1.2 2005-08-27 Remember chooser panel. <br>
033:         *          1.1 2005-04-23 Removed main method. <br>
034:         *          1.0 30 March 2005 Created.
035:         */
036:        public class ColorChooserMainPanel extends javax.swing.JPanel {
037:            /**
038:             * We store here the name of the last selected chooser. When the
039:             * ColorChooserMainPanel is recreated multiple times in the same applicatin,
040:             * the application 'remembers' which panel the user had opened before.
041:             */
042:            private static String lastSelectedChooserName = null;
043:
044:            /** Creates new form. */
045:            public ColorChooserMainPanel() {
046:                initComponents();
047:                toolBar.putClientProperty("Quaqua.ToolBar.isDividerDrawn",
048:                        Boolean.TRUE);
049:
050:            }
051:
052:            public void setPreviewPanel(JComponent c) {
053:                previewPanelHolder.removeAll();
054:                if (c != null) {
055:                    previewPanelHolder.add(c);
056:                }
057:            }
058:
059:            public void addColorChooserPanel(final AbstractColorChooserPanel ccp) {
060:                final String displayName = ccp.getDisplayName();
061:
062:                if (displayName.equals("Color Picker")) {
063:                    northPanel.add(ccp, BorderLayout.WEST);
064:                } else {
065:                    Icon displayIcon = ccp.getLargeDisplayIcon();
066:                    JToggleButton tb = new JToggleButton(null, displayIcon);
067:                    tb.setToolTipText(displayName);
068:                    Methods.invokeIfExists(tb, "setFocusable", false);
069:                    tb.setHorizontalTextPosition(SwingConstants.CENTER);
070:                    tb.setVerticalTextPosition(SwingConstants.BOTTOM);
071:                    tb.setFont(UIManager.getFont("ColorChooser.font"));
072:                    tb.putClientProperty("Quaqua.Button.style", "toolBarTab");
073:                    JPanel centerView = new JPanel(new BorderLayout());
074:                    centerView.add(ccp);
075:                    chooserPanelHolder.add(centerView, displayName);
076:                    toolBarButtonGroup.add(tb);
077:                    toolBar.add(tb);
078:
079:                    if (toolBar.getComponentCount() == 1
080:                            || lastSelectedChooserName != null
081:                            && lastSelectedChooserName.equals(displayName)) {
082:                        tb.setSelected(true);
083:                        CardLayout cl = (CardLayout) chooserPanelHolder
084:                                .getLayout();
085:                        cl.show(chooserPanelHolder, displayName);
086:                    }
087:
088:                    tb.addItemListener(new ItemListener() {
089:                        public void itemStateChanged(ItemEvent evt) {
090:                            if (evt.getStateChange() == ItemEvent.SELECTED) {
091:                                CardLayout cl = (CardLayout) chooserPanelHolder
092:                                        .getLayout();
093:                                cl.show(chooserPanelHolder, displayName);
094:                                lastSelectedChooserName = displayName;
095:                            }
096:                        }
097:                    });
098:                }
099:            }
100:
101:            public void removeAllColorChooserPanels() {
102:                Component[] tb = toolBar.getComponents();
103:                for (int i = 0; i < tb.length; i++) {
104:                    if (tb[i] instanceof  AbstractButton) {
105:                        toolBarButtonGroup.remove((AbstractButton) tb[i]);
106:                    }
107:                }
108:                toolBar.removeAll();
109:                chooserPanelHolder.removeAll();
110:
111:                northPanel.removeAll();
112:                northPanel.add(previewPanelHolder);
113:            }
114:
115:            /**
116:             * This method is called from within the constructor to initialize the form.
117:             * WARNING: Do NOT modify this code. The content of this method is always
118:             * regenerated by the Form Editor.
119:             */
120:            private void initComponents() {// GEN-BEGIN:initComponents
121:                toolBarButtonGroup = new javax.swing.ButtonGroup();
122:                toolBar = new javax.swing.JToolBar();
123:                mainPanel = new javax.swing.JPanel();
124:                northPanel = new javax.swing.JPanel();
125:                previewPanelHolder = new javax.swing.JPanel();
126:                chooserPanelHolder = new javax.swing.JPanel();
127:
128:                setLayout(new java.awt.BorderLayout());
129:
130:                toolBar.setFloatable(false);
131:                add(toolBar, java.awt.BorderLayout.NORTH);
132:
133:                mainPanel.setLayout(new java.awt.BorderLayout());
134:
135:                mainPanel.setBorder(new javax.swing.border.EmptyBorder(
136:                        new java.awt.Insets(5, 4, 7, 4)));
137:                northPanel.setLayout(new java.awt.BorderLayout());
138:
139:                previewPanelHolder.setLayout(new java.awt.BorderLayout());
140:
141:                northPanel
142:                        .add(previewPanelHolder, java.awt.BorderLayout.CENTER);
143:
144:                mainPanel.add(northPanel, java.awt.BorderLayout.NORTH);
145:
146:                chooserPanelHolder.setLayout(new java.awt.CardLayout());
147:
148:                chooserPanelHolder
149:                        .setBorder(new javax.swing.border.EmptyBorder(
150:                                new java.awt.Insets(5, 0, 0, 0)));
151:                mainPanel.add(chooserPanelHolder, java.awt.BorderLayout.CENTER);
152:
153:                add(mainPanel, java.awt.BorderLayout.CENTER);
154:
155:            }// GEN-END:initComponents
156:
157:            // Variables declaration - do not modify//GEN-BEGIN:variables
158:            private javax.swing.JPanel chooserPanelHolder;
159:            private javax.swing.JPanel mainPanel;
160:            private javax.swing.JPanel northPanel;
161:            private javax.swing.JPanel previewPanelHolder;
162:            private javax.swing.JToolBar toolBar;
163:            private javax.swing.ButtonGroup toolBarButtonGroup;
164:            // End of variables declaration//GEN-END:variables
165:
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.