Source Code Cross Referenced for CheckBoxTreeCellRenderer.java in  » Swing-Library » jide-common » com » jidesoft » swing » 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 » jide common » com.jidesoft.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)CheckBoxTreeCellRenderer.java 8/11/2005
003:         *
004:         * Copyright 2002 - 2005 JIDE Software Inc. All rights reserved.
005:         */
006:
007:        package com.jidesoft.swing;
008:
009:        import javax.swing.*;
010:        import javax.swing.border.Border;
011:        import javax.swing.border.EmptyBorder;
012:        import javax.swing.tree.TreeCellRenderer;
013:        import javax.swing.tree.TreePath;
014:        import java.awt.*;
015:        import java.awt.event.MouseEvent;
016:        import java.io.Serializable;
017:
018:        /**
019:         * Renderers an item in a tree using JCheckBox.
020:         */
021:        public class CheckBoxTreeCellRenderer extends NullPanel implements 
022:                TreeCellRenderer, Serializable {
023:
024:            protected static Border noFocusBorder;
025:
026:            /**
027:             * The checkbox that is used to paint the check box in cell renderer
028:             */
029:            protected TristateCheckBox _checkBox = new NullTristateCheckBox();
030:            protected JCheckBox PROTOTYPE = new TristateCheckBox();
031:            protected JLabel _label = new NullLabel();
032:
033:            /**
034:             * The label which appears after the check box.
035:             */
036:            protected TreeCellRenderer _actualTreeRenderer;
037:
038:            /**
039:             * Constructs a default renderer object for an item
040:             * in a list.
041:             */
042:            public CheckBoxTreeCellRenderer() {
043:                this (null);
044:            }
045:
046:            public CheckBoxTreeCellRenderer(TreeCellRenderer renderer) {
047:                if (noFocusBorder == null) {
048:                    noFocusBorder = new EmptyBorder(1, 1, 1, 1);
049:                }
050:                _checkBox.setOpaque(false);
051:                setBorder(noFocusBorder);
052:                setLayout(new BorderLayout(0, 0));
053:                add(_checkBox, BorderLayout.BEFORE_LINE_BEGINS);
054:                _actualTreeRenderer = renderer;
055:            }
056:
057:            public TreeCellRenderer getActualTreeRenderer() {
058:                return _actualTreeRenderer;
059:            }
060:
061:            public void setActualTreeRenderer(
062:                    TreeCellRenderer actualTreeRenderer) {
063:                _actualTreeRenderer = actualTreeRenderer;
064:            }
065:
066:            public Component getTreeCellRendererComponent(JTree tree,
067:                    Object value, boolean selected, boolean expanded,
068:                    boolean leaf, int row, boolean hasFocus) {
069:                _checkBox.setPreferredSize(new Dimension(PROTOTYPE
070:                        .getPreferredSize().width, 0));
071:                setComponentOrientation(tree.getComponentOrientation());
072:
073:                TreePath path = tree.getPathForRow(row);
074:                if (path != null && tree instanceof  CheckBoxTree) {
075:                    CheckBoxTreeSelectionModel selectionModel = ((CheckBoxTree) tree)
076:                            .getCheckBoxTreeSelectionModel();
077:                    if (selectionModel != null) {
078:                        _checkBox.setEnabled(((CheckBoxTree) tree)
079:                                .isCheckBoxEnabled()
080:                                && ((CheckBoxTree) tree)
081:                                        .isCheckBoxEnabled(path));
082:                        if (selectionModel.isPathSelected(path, selectionModel
083:                                .isDigIn()))
084:                            _checkBox.setState(TristateCheckBox.SELECTED);
085:                        else
086:                            _checkBox
087:                                    .setState(selectionModel.isDigIn()
088:                                            && selectionModel
089:                                                    .isPartiallySelected(path) ? null
090:                                            : TristateCheckBox.NOT_SELECTED);
091:                    }
092:                }
093:
094:                if (_actualTreeRenderer != null) {
095:                    JComponent treeCellRendererComponent = (JComponent) _actualTreeRenderer
096:                            .getTreeCellRendererComponent(tree, value,
097:                                    selected, expanded, leaf, row, hasFocus);
098:                    if (path != null && tree instanceof  CheckBoxTree) {
099:                        if (!((CheckBoxTree) tree).isCheckBoxVisible(path)) {
100:                            return treeCellRendererComponent;
101:                        }
102:                    }
103:                    Border border = treeCellRendererComponent.getBorder();
104:                    setBorder(border);
105:                    treeCellRendererComponent.setBorder(BorderFactory
106:                            .createEmptyBorder());
107:                    if (getComponentCount() == 2) {
108:                        remove(1);
109:                    }
110:                    add(treeCellRendererComponent);
111:                }
112:
113:                return this ;
114:            }
115:
116:            @Override
117:            public String getToolTipText(MouseEvent event) {
118:                if (_actualTreeRenderer instanceof  JComponent) {
119:                    Point p = event.getPoint();
120:                    p.translate(-_checkBox.getWidth(), 0);
121:                    MouseEvent newEvent = new MouseEvent(
122:                            ((JComponent) _actualTreeRenderer), event.getID(),
123:                            event.getWhen(), event.getModifiers(), p.x, p.y,
124:                            event.getClickCount(), event.isPopupTrigger());
125:
126:                    String tip = ((JComponent) _actualTreeRenderer)
127:                            .getToolTipText(newEvent);
128:
129:                    if (tip != null) {
130:                        return tip;
131:                    }
132:                }
133:                return super.getToolTipText(event);
134:            }
135:
136:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.