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


001:        /*
002:         * @(#)StyledListCellRenderer.java 8/11/2005
003:         *
004:         * Copyright 2002 - 2005 JIDE Software Inc. All rights reserved.
005:         */
006:
007:        package com.jidesoft.list;
008:
009:        import com.jidesoft.plaf.UIDefaultsLookup;
010:        import com.jidesoft.swing.StyledLabel;
011:
012:        import javax.swing.*;
013:        import javax.swing.border.Border;
014:        import javax.swing.border.EmptyBorder;
015:        import java.awt.*;
016:        import java.io.Serializable;
017:
018:        /**
019:         * A list cell renderer based on StyledLabel.
020:         * To use it, you should make your cell renderer extending this one and override
021:         * {@link #customizeStyledLabel(javax.swing.JList,Object,int,boolean,boolean)} method.
022:         * If your overridden method, you can call setStyleRange() or setStyleRanges() based on
023:         * the item value, if it is leaf etc information.
024:         */
025:        public class StyledListCellRenderer extends StyledLabel implements 
026:                ListCellRenderer, Serializable {
027:
028:            protected static Border noFocusBorder;
029:
030:            /**
031:             * Constructs a default renderer object for an item
032:             * in a list.
033:             */
034:            public StyledListCellRenderer() {
035:                super ();
036:                if (noFocusBorder == null) {
037:                    noFocusBorder = new EmptyBorder(1, 1, 1, 1);
038:                }
039:                setOpaque(true);
040:                setBorder(noFocusBorder);
041:            }
042:
043:            public Component getListCellRendererComponent(JList list,
044:                    Object value, int index, boolean isSelected,
045:                    boolean cellHasFocus) {
046:                setComponentOrientation(list.getComponentOrientation());
047:                if (isSelected) {
048:                    setBackground(list.getSelectionBackground());
049:                    setForeground(list.getSelectionForeground());
050:                } else {
051:                    setBackground(list.getBackground());
052:                    setForeground(list.getForeground());
053:                }
054:
055:                setIgnoreColorSettings(isSelected);
056:                customizeStyledLabel(list, value, index, isSelected,
057:                        cellHasFocus);
058:
059:                setEnabled(list.isEnabled());
060:                setFont(list.getFont());
061:
062:                Border border = null;
063:                if (cellHasFocus) {
064:                    if (isSelected) {
065:                        border = UIDefaultsLookup
066:                                .getBorder("List.focusSelectedCellHighlightBorder");
067:                    }
068:                    if (border == null) {
069:                        border = UIDefaultsLookup
070:                                .getBorder("List.focusCellHighlightBorder");
071:                    }
072:                } else {
073:                    border = noFocusBorder;
074:                }
075:                setBorder(border);
076:
077:                return this ;
078:            }
079:
080:            /**
081:             * Overrides this method to customize the styled label.
082:             *
083:             * @param list
084:             * @param value
085:             * @param index
086:             * @param isSelected
087:             * @param cellHasFocus
088:             */
089:            protected void customizeStyledLabel(JList list, Object value,
090:                    int index, boolean isSelected, boolean cellHasFocus) {
091:                clearStyleRanges();
092:                if (value instanceof  Icon) {
093:                    setIcon((Icon) value);
094:                    setText("");
095:                } else {
096:                    setIcon(null);
097:                    setText((value == null) ? "" : value.toString());
098:                }
099:            }
100:
101:            /**
102:             * Overridden for performance reasons.
103:             * See the <a href="#override">Implementation Note</a>
104:             * for more information.
105:             *
106:             * @return <code>true</code> if the background is completely opaque
107:             *         and differs from the JList's background;
108:             *         <code>false</code> otherwise
109:             * @since 1.5
110:             */
111:            @Override
112:            public boolean isOpaque() {
113:                Color back = getBackground();
114:                Component p = getParent();
115:                if (p != null) {
116:                    p = p.getParent();
117:                }
118:                // p should now be the JList.
119:                boolean colorMatch = (back != null) && (p != null)
120:                        && back.equals(p.getBackground()) && p.isOpaque();
121:                return !colorMatch && super .isOpaque();
122:            }
123:
124:            /**
125:             * Overridden for performance reasons.
126:             * See the <a href="#override">Implementation Note</a>
127:             * for more information.
128:             */
129:            @Override
130:            public void validate() {
131:            }
132:
133:            /**
134:             * Overridden for performance reasons.
135:             * See the <a href="#override">Implementation Note</a>
136:             * for more information.
137:             *
138:             * @since 1.5
139:             */
140:            @Override
141:            public void invalidate() {
142:            }
143:
144:            /**
145:             * Overridden for performance reasons.
146:             * See the <a href="#override">Implementation Note</a>
147:             * for more information.
148:             *
149:             * @since 1.5
150:             */
151:            @Override
152:            public void repaint() {
153:            }
154:
155:            /**
156:             * Overridden for performance reasons.
157:             * See the <a href="#override">Implementation Note</a>
158:             * for more information.
159:             */
160:            @Override
161:            public void revalidate() {
162:            }
163:
164:            /**
165:             * Overridden for performance reasons.
166:             * See the <a href="#override">Implementation Note</a>
167:             * for more information.
168:             */
169:            @Override
170:            public void repaint(long tm, int x, int y, int width, int height) {
171:            }
172:
173:            /**
174:             * Overridden for performance reasons.
175:             * See the <a href="#override">Implementation Note</a>
176:             * for more information.
177:             */
178:            @Override
179:            public void repaint(Rectangle r) {
180:            }
181:
182:            /**
183:             * Overridden for performance reasons.
184:             * See the <a href="#override">Implementation Note</a>
185:             * for more information.
186:             */
187:            @Override
188:            protected void firePropertyChange(String propertyName,
189:                    Object oldValue, Object newValue) {
190:                // Strings get interned...
191:                if (propertyName.equals("text"))
192:                    super .firePropertyChange(propertyName, oldValue, newValue);
193:            }
194:
195:            /**
196:             * Overridden for performance reasons.
197:             * See the <a href="#override">Implementation Note</a>
198:             * for more information.
199:             */
200:            @Override
201:            public void firePropertyChange(String propertyName, byte oldValue,
202:                    byte newValue) {
203:            }
204:
205:            /**
206:             * Overridden for performance reasons.
207:             * See the <a href="#override">Implementation Note</a>
208:             * for more information.
209:             */
210:            @Override
211:            public void firePropertyChange(String propertyName, char oldValue,
212:                    char newValue) {
213:            }
214:
215:            /**
216:             * Overridden for performance reasons.
217:             * See the <a href="#override">Implementation Note</a>
218:             * for more information.
219:             */
220:            @Override
221:            public void firePropertyChange(String propertyName, short oldValue,
222:                    short newValue) {
223:            }
224:
225:            /**
226:             * Overridden for performance reasons.
227:             * See the <a href="#override">Implementation Note</a>
228:             * for more information.
229:             */
230:            @Override
231:            public void firePropertyChange(String propertyName, int oldValue,
232:                    int newValue) {
233:            }
234:
235:            /**
236:             * Overridden for performance reasons.
237:             * See the <a href="#override">Implementation Note</a>
238:             * for more information.
239:             */
240:            @Override
241:            public void firePropertyChange(String propertyName, long oldValue,
242:                    long newValue) {
243:            }
244:
245:            /**
246:             * Overridden for performance reasons.
247:             * See the <a href="#override">Implementation Note</a>
248:             * for more information.
249:             */
250:            @Override
251:            public void firePropertyChange(String propertyName, float oldValue,
252:                    float newValue) {
253:            }
254:
255:            /**
256:             * Overridden for performance reasons.
257:             * See the <a href="#override">Implementation Note</a>
258:             * for more information.
259:             */
260:            @Override
261:            public void firePropertyChange(String propertyName,
262:                    double oldValue, double newValue) {
263:            }
264:
265:            /**
266:             * Overridden for performance reasons.
267:             * See the <a href="#override">Implementation Note</a>
268:             * for more information.
269:             */
270:            @Override
271:            public void firePropertyChange(String propertyName,
272:                    boolean oldValue, boolean newValue) {
273:            }
274:
275:            /**
276:             * A subclass of DefaultListCellRenderer that implements UIResource.
277:             * DefaultListCellRenderer doesn't implement UIResource
278:             * directly so that applications can safely override the
279:             * cellRenderer property with DefaultListCellRenderer subclasses.
280:             * <p/>
281:             * <strong>Warning:</strong>
282:             * Serialized objects of this class will not be compatible with
283:             * future Swing releases. The current serialization support is
284:             * appropriate for short term storage or RMI between applications running
285:             * the same version of Swing.  As of 1.4, support for long term storage
286:             * of all JavaBeans<sup><font size="-2">TM</font></sup>
287:             * has been added to the <code>java.beans</code> package.
288:             * Please see {@link java.beans.XMLEncoder}.
289:             */
290:            public static class UIResource extends StyledListCellRenderer
291:                    implements  javax.swing.plaf.UIResource {
292:            }
293:
294:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.