Source Code Cross Referenced for ComponentStructureCellRenderer.java in  » Web-Framework » webonswing » net » ar » webonswing » tutorial » tree » 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 » Web Framework » webonswing » net.ar.webonswing.tutorial.tree 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.ar.webonswing.tutorial.tree;
002:
003:        import java.awt.*;
004:
005:        import javax.swing.*;
006:        import javax.swing.plaf.*;
007:        import javax.swing.tree.*;
008:
009:        import net.ar.webonswing.*;
010:        import net.ar.webonswing.helpers.*;
011:        import net.ar.webonswing.render.templates.*;
012:        import net.ar.webonswing.swing.components.*;
013:        import net.ar.webonswing.swing.layouts.*;
014:
015:        public class ComponentStructureCellRenderer implements  TreeCellRenderer {
016:            MyCell theLeafCell;
017:            MyCell theExpandedCell;
018:            MyCell theCollapsedCell;
019:            MyCell theRootCell;
020:            Template theTemplate;
021:
022:            public ComponentStructureCellRenderer(JTree aTree) {
023:                theTemplate = WosSwingHelper.getTemplateForComponent("JTree2",
024:                        aTree);
025:
026:                theLeafCell = createCell("theLeafNode", new ImageIcon(
027:                        "resources/images/j.close.gif"));
028:                theExpandedCell = createCell("theExpandedNode", new ImageIcon(
029:                        "resources/images/j.open.gif"));
030:                theCollapsedCell = createCell("theCollapsedNode",
031:                        new ImageIcon("resources/images/j.close.gif"));
032:                theRootCell = createCell("theRootNode", new ImageIcon(
033:                        "resources/images/j.close.gif"));
034:            }
035:
036:            private MyCell createCell(String theNodeType, ImageIcon aIcon) {
037:                JCheckBox theCheck = new JCheckBox();
038:                JLabel theLabel = new JLabel();
039:
040:                theCheck.setLayout(new TemplateLayout(WosFramework
041:                        .getKeyPositionTemplateForSubTemplate(theTemplate,
042:                                theNodeType
043:                                        + ".theTreeCell.theContent.theCheck")));
044:                theLabel.setLayout(new TemplateLayout(WosFramework
045:                        .getKeyPositionTemplateForSubTemplate(theTemplate,
046:                                theNodeType
047:                                        + ".theTreeCell.theContent.theLabel")));
048:
049:                MyCell theCell = new MyCell(new TemplateLayout(WosFramework
050:                        .getKeyPositionTemplateForSubTemplate(theTemplate,
051:                                theNodeType + ".theTreeCell.theContent")),
052:                        theCheck, "theCheck", theLabel, "theLabel");
053:                theCell.theLabel.setIcon(aIcon);
054:
055:                return theCell;
056:            }
057:
058:            public Component getTreeCellRendererComponent(JTree aTree,
059:                    Object value, boolean isSelected, boolean expanded,
060:                    boolean leaf, int row, boolean hasFocus) {
061:                MyCell theCell = null;
062:
063:                if (value instanceof  CheckNode) {
064:                    TreeNode theRootNode = (TreeNode) aTree.getModel()
065:                            .getRoot();
066:                    CheckNode theCheckNode = (CheckNode) value;
067:                    theCell = theRootNode == theCheckNode ? theRootCell
068:                            : leaf ? theLeafCell : expanded ? theExpandedCell
069:                                    : theCollapsedCell;
070:
071:                    theCell.setEnabled(aTree.isEnabled());
072:                    theCell.theCheck.setSelected(theCheckNode.isSelected());
073:                    theCell.theLabel.setText(aTree.convertValueToText(value,
074:                            isSelected, expanded, leaf, row, hasFocus));
075:
076:                    Color theBgColor = isSelected ? new ColorUIResource(255,
077:                            255, 200) : UIManager.getColor("Label.background");
078:                    theCell.theLabel.setBackground(theBgColor);
079:                }
080:
081:                return theCell;
082:            }
083:
084:            class MyCell extends JPanel {
085:                JCheckBox theCheck;
086:                JLabel theLabel;
087:
088:                public MyCell(LayoutManager aLayout, JCheckBox aCheck,
089:                        String aCheckPosition, JLabel aLabel,
090:                        String aLabelPosition) {
091:                    super (aLayout);
092:
093:                    add(theCheck = aCheck, aCheckPosition);
094:                    add(theLabel = aLabel, aLabelPosition);
095:                }
096:
097:                public Dimension getPreferredSize() {
098:                    Dimension d_check = theCheck.getPreferredSize();
099:                    Dimension d_label = theLabel.getPreferredSize();
100:                    return new Dimension(d_check.width + d_label.width,
101:                            (d_check.height < d_label.height ? d_label.height
102:                                    : d_check.height));
103:                }
104:
105:                public void setBackground(Color color) {
106:                    if (color instanceof  ColorUIResource)
107:                        color = null;
108:
109:                    super .setBackground(color);
110:                }
111:
112:                public JCheckBox getCheck() {
113:                    return theCheck;
114:                }
115:
116:                public void setCheck(JCheckBox aCheck) {
117:                    theCheck = aCheck;
118:                }
119:
120:                public JLabel getLabel() {
121:                    return theLabel;
122:                }
123:
124:                public void setLabel(JLabel aLabel) {
125:                    theLabel = aLabel;
126:                }
127:            }
128:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.