Source Code Cross Referenced for TreePanel.java in  » Swing-Library » substance-look-feel » test » check » 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 » test.check 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved.
003:         *
004:         * Redistribution and use in source and binary forms, with or without 
005:         * modification, are permitted provided that the following conditions are met:
006:         * 
007:         *  o Redistributions of source code must retain the above copyright notice, 
008:         *    this list of conditions and the following disclaimer. 
009:         *     
010:         *  o Redistributions in binary form must reproduce the above copyright notice, 
011:         *    this list of conditions and the following disclaimer in the documentation 
012:         *    and/or other materials provided with the distribution. 
013:         *     
014:         *  o Neither the name of Substance Kirill Grouchnikov nor the names of 
015:         *    its contributors may be used to endorse or promote products derived 
016:         *    from this software without specific prior written permission. 
017:         *     
018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
020:         * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
021:         * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
022:         * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
023:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
024:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
025:         * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026:         * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
027:         * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
028:         * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
029:         */
030:        package test.check;
031:
032:        import java.awt.*;
033:        import java.awt.event.ActionEvent;
034:        import java.awt.event.ActionListener;
035:
036:        import javax.swing.*;
037:        import javax.swing.border.EmptyBorder;
038:        import javax.swing.event.ChangeEvent;
039:        import javax.swing.event.ChangeListener;
040:        import javax.swing.tree.DefaultMutableTreeNode;
041:
042:        import org.jvnet.lafwidget.LafWidget;
043:        import org.jvnet.lafwidget.animation.FadeConfigurationManager;
044:        import org.jvnet.substance.SubstanceDefaultTreeCellRenderer;
045:        import org.jvnet.substance.SubstanceLookAndFeel;
046:
047:        import test.Check;
048:
049:        import com.jgoodies.forms.builder.DefaultFormBuilder;
050:        import com.jgoodies.forms.layout.FormLayout;
051:
052:        /**
053:         * Test application panel for testing {@link JTree} component.
054:         * 
055:         * @author Kirill Grouchnikov
056:         */
057:        public class TreePanel extends ControllablePanel {
058:            /**
059:             * The cell renderer for the tree. Uses HTML for bold text on selected row
060:             * and custom icon on selected row.
061:             * 
062:             * @author Kirill Grouchnikov
063:             */
064:            private static class TestTreeCellRenderer extends
065:                    SubstanceDefaultTreeCellRenderer {
066:                public Component getTreeCellRendererComponent(JTree tree,
067:                        Object value, boolean sel, boolean expanded,
068:                        boolean leaf, int row, boolean hasFocus) {
069:                    JLabel result = (JLabel) super 
070:                            .getTreeCellRendererComponent(tree, value, sel,
071:                                    expanded, leaf, row, hasFocus);
072:                    if (sel) {
073:                        result.setText("<html><b>" + getText() + "</b></html>");
074:                        result.setIcon(Check.getIcon("flag_sweden"));
075:                    }
076:                    return result;
077:                }
078:            }
079:
080:            /**
081:             * The tree component.
082:             */
083:            private JTree tree;
084:
085:            /**
086:             * The scroll pane that contains the tree.
087:             */
088:            private JScrollPane jsp;
089:
090:            /**
091:             * Creates the tree panel.
092:             */
093:            public TreePanel() {
094:                this .setLayout(new BorderLayout());
095:
096:                DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
097:                DefaultMutableTreeNode son1 = new DefaultMutableTreeNode("son1");
098:                DefaultMutableTreeNode son2 = new DefaultMutableTreeNode("son2");
099:                DefaultMutableTreeNode son3 = new DefaultMutableTreeNode("son3");
100:                DefaultMutableTreeNode gson11 = new DefaultMutableTreeNode(
101:                        "gson11");
102:                DefaultMutableTreeNode gson12 = new DefaultMutableTreeNode(
103:                        "gson12");
104:                DefaultMutableTreeNode gson21 = new DefaultMutableTreeNode(
105:                        "gson21");
106:                DefaultMutableTreeNode gson22 = new DefaultMutableTreeNode(
107:                        "gson22");
108:                DefaultMutableTreeNode gson31 = new DefaultMutableTreeNode(
109:                        "gson31");
110:                DefaultMutableTreeNode gson32 = new DefaultMutableTreeNode(
111:                        "gson32");
112:                DefaultMutableTreeNode ggson111 = new DefaultMutableTreeNode(
113:                        "ggson111");
114:                DefaultMutableTreeNode ggson112 = new DefaultMutableTreeNode(
115:                        "ggson112");
116:                DefaultMutableTreeNode ggson113 = new DefaultMutableTreeNode(
117:                        "ggson113");
118:
119:                gson11.add(ggson111);
120:                gson11.add(ggson112);
121:                gson11.add(ggson113);
122:                son1.add(gson11);
123:                son1.add(gson12);
124:                son2.add(gson21);
125:                son2.add(gson22);
126:                son3.add(gson31);
127:                son3.add(gson32);
128:                root.add(son1);
129:                root.add(son2);
130:                root.add(son3);
131:
132:                this .tree = new JTree(root);
133:                // {
134:                // public Insets getInsets() {
135:                // return new Insets(5, 5, 5, 5);
136:                // }
137:                // };
138:                // this.tree.setCellRenderer(new TestTreeCellRenderer());
139:                this .tree.putClientProperty(LafWidget.TREE_AUTO_DND_SUPPORT,
140:                        Boolean.TRUE);
141:                this .jsp = new JScrollPane(this .tree);
142:                this .jsp.setBorder(new EmptyBorder(0, 0, 0, 0));
143:                this .add(this .jsp, BorderLayout.CENTER);
144:
145:                FormLayout lm = new FormLayout(
146:                        "right:pref, 4dlu, fill:pref:grow", "");
147:                DefaultFormBuilder builder = new DefaultFormBuilder(lm,
148:                        new ScrollablePanel());
149:                builder.appendSeparator("General");
150:
151:                final JCheckBox isEnabled = new JCheckBox("is enabled");
152:                isEnabled.setSelected(tree.isEnabled());
153:                isEnabled.addActionListener(new ActionListener() {
154:                    public void actionPerformed(ActionEvent e) {
155:                        tree.setEnabled(isEnabled.isSelected());
156:                    }
157:                });
158:                builder.append("Enabled", isEnabled);
159:
160:                final JCheckBox isOpaque = new JCheckBox("is opaque");
161:                isOpaque.setSelected(tree.isOpaque());
162:                isOpaque.addActionListener(new ActionListener() {
163:                    public void actionPerformed(ActionEvent e) {
164:                        tree.setOpaque(isOpaque.isSelected());
165:                        tree.repaint();
166:                    }
167:                });
168:                builder.append("Opacity", isOpaque);
169:
170:                final JCheckBox isEditable = new JCheckBox("is editable");
171:                isEditable.setSelected(tree.isEditable());
172:                isEditable.addActionListener(new ActionListener() {
173:                    public void actionPerformed(ActionEvent e) {
174:                        tree.setEditable(isEditable.isSelected());
175:                    }
176:                });
177:                builder.append("Editable", isEditable);
178:
179:                final JCheckBox watermarkBleed = new JCheckBox("is bleeding");
180:                watermarkBleed.addActionListener(new ActionListener() {
181:                    public void actionPerformed(ActionEvent e) {
182:                        tree.putClientProperty(
183:                                SubstanceLookAndFeel.WATERMARK_TO_BLEED,
184:                                Boolean.valueOf(watermarkBleed.isSelected()));
185:                        jsp.putClientProperty(
186:                                SubstanceLookAndFeel.WATERMARK_TO_BLEED,
187:                                Boolean.valueOf(watermarkBleed.isSelected()));
188:                        tree.repaint();
189:                    }
190:                });
191:                builder.append("Watermark", watermarkBleed);
192:
193:                final JCheckBox isWrappedInScrollPane = new JCheckBox(
194:                        "is in scroll pane");
195:                isWrappedInScrollPane.setSelected(true);
196:                isWrappedInScrollPane.addActionListener(new ActionListener() {
197:                    public void actionPerformed(ActionEvent e) {
198:                        if (isWrappedInScrollPane.isSelected()) {
199:                            remove(tree);
200:                            jsp.setViewportView(tree);
201:                            add(jsp, BorderLayout.CENTER);
202:                        } else {
203:                            remove(jsp);
204:                            add(tree, BorderLayout.CENTER);
205:                        }
206:                        revalidate();
207:                        repaint();
208:                    }
209:                });
210:                builder.append("Container", isWrappedInScrollPane);
211:
212:                final JCheckBox cbTreeDecorations = new JCheckBox(
213:                        "animate tree decorations");
214:                cbTreeDecorations.addActionListener(new ActionListener() {
215:                    public void actionPerformed(ActionEvent e) {
216:                        if (cbTreeDecorations.isSelected()) {
217:                            FadeConfigurationManager
218:                                    .getInstance()
219:                                    .allowFades(
220:                                            SubstanceLookAndFeel.TREE_DECORATIONS_ANIMATION_KIND,
221:                                            tree);
222:                        } else {
223:                            FadeConfigurationManager
224:                                    .getInstance()
225:                                    .disallowFades(
226:                                            SubstanceLookAndFeel.TREE_DECORATIONS_ANIMATION_KIND,
227:                                            tree);
228:                        }
229:                        tree.repaint();
230:                    }
231:                });
232:                builder.append("Decorations", cbTreeDecorations);
233:
234:                final JCheckBox rendererCB = new JCheckBox(
235:                        "has custom renderer");
236:                rendererCB.addActionListener(new ActionListener() {
237:                    public void actionPerformed(ActionEvent e) {
238:                        SwingUtilities.invokeLater(new Runnable() {
239:                            public void run() {
240:                                if (rendererCB.isSelected()) {
241:                                    tree
242:                                            .setCellRenderer(new TestTreeCellRenderer());
243:                                } else {
244:                                    tree
245:                                            .setCellRenderer(new SubstanceDefaultTreeCellRenderer());
246:                                }
247:                            }
248:                        });
249:                    }
250:                });
251:                builder.append("Renderer", rendererCB);
252:
253:                builder.appendSeparator("Insets");
254:                Insets ins = tree.getInsets();
255:                final JSpinner topInsets = new JSpinner(new SpinnerNumberModel(
256:                        ins.top, 0, 10, 1));
257:                final JSpinner leftInsets = new JSpinner(
258:                        new SpinnerNumberModel(ins.left, 0, 10, 1));
259:                final JSpinner bottomInsets = new JSpinner(
260:                        new SpinnerNumberModel(ins.bottom, 0, 10, 1));
261:                final JSpinner rightInsets = new JSpinner(
262:                        new SpinnerNumberModel(ins.right, 0, 10, 1));
263:                builder.append("Top", topInsets);
264:                builder.append("Left", leftInsets);
265:                builder.append("Bottom", bottomInsets);
266:                builder.append("Right", rightInsets);
267:
268:                ChangeListener cl = new ChangeListener() {
269:                    public void stateChanged(ChangeEvent e) {
270:                        tree.setBorder(new EmptyBorder((Integer) topInsets
271:                                .getValue(), (Integer) leftInsets.getValue(),
272:                                (Integer) bottomInsets.getValue(),
273:                                (Integer) rightInsets.getValue()));
274:                    }
275:                };
276:                topInsets.addChangeListener(cl);
277:                leftInsets.addChangeListener(cl);
278:                bottomInsets.addChangeListener(cl);
279:                rightInsets.addChangeListener(cl);
280:
281:                this .controlPanel = builder.getPanel();
282:                // this.tree.setEditable(true);
283:            }
284:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.