Source Code Cross Referenced for ExtendedTableCellRenderer.java in  » Byte-Code » jclasslib » org » gjt » jclasslib » util » 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 » Byte Code » jclasslib » org.gjt.jclasslib.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:            This library is free software; you can redistribute it and/or
003:            modify it under the terms of the GNU General Public
004:            License as published by the Free Software Foundation; either
005:            version 2 of the license, or (at your option) any later version.
006:         */
007:
008:        package org.gjt.jclasslib.util;
009:
010:        import javax.swing.*;
011:        import javax.swing.border.Border;
012:        import javax.swing.border.EmptyBorder;
013:        import javax.swing.table.TableCellRenderer;
014:        import java.awt.*;
015:
016:        /**
017:         A <tt>TableCellRenderer</tt> which is based on an <tt>ExtendedJLabel</tt> rather than
018:         a <tt>JLabel</tt> like the <tt>javax.swing.table.DefaultTableCellRenderer</tt>.
019:
020:         @author <a href="mailto:jclasslib@ej-technologies.com">Ingo Kegel</a>
021:         @version $Revision: 1.4 $ $Date: 2003/08/18 07:48:28 $
022:         */
023:        public class ExtendedTableCellRenderer extends ExtendedJLabel implements 
024:                TableCellRenderer {
025:
026:            private static final Border NO_FOCUS_BORDER = new EmptyBorder(1, 1,
027:                    1, 1);
028:
029:            private Color unselectedForeground;
030:            private Color unselectedBackground;
031:
032:            /**
033:             * Constructor.
034:             */
035:            public ExtendedTableCellRenderer() {
036:                super ();
037:                setOpaque(true);
038:                setBorder(NO_FOCUS_BORDER);
039:            }
040:
041:            public void setForeground(Color c) {
042:                super .setForeground(c);
043:                unselectedForeground = c;
044:            }
045:
046:            public void setBackground(Color c) {
047:                super .setBackground(c);
048:                unselectedBackground = c;
049:            }
050:
051:            public void updateUI() {
052:                super .updateUI();
053:                setForeground(null);
054:                setBackground(null);
055:            }
056:
057:            public Component getTableCellRendererComponent(JTable table,
058:                    Object value, boolean isSelected, boolean hasFocus,
059:                    int row, int column) {
060:                if (isSelected) {
061:                    super .setForeground(table.getSelectionForeground());
062:                    super .setBackground(table.getSelectionBackground());
063:
064:                } else {
065:                    super 
066:                            .setForeground((unselectedForeground != null) ? unselectedForeground
067:                                    : table.getForeground());
068:                    super 
069:                            .setBackground((unselectedBackground != null) ? unselectedBackground
070:                                    : table.getBackground());
071:                }
072:
073:                setFont(table.getFont());
074:
075:                if (hasFocus) {
076:                    setBorder(UIManager
077:                            .getBorder("Table.focusCellHighlightBorder"));
078:                    if (table.isCellEditable(row, column)) {
079:                        super .setForeground(UIManager
080:                                .getColor("Table.focusCellForeground"));
081:                        super .setBackground(UIManager
082:                                .getColor("Table.focusCellBackground"));
083:                    }
084:                } else {
085:                    setBorder(NO_FOCUS_BORDER);
086:                }
087:
088:                setValue(value);
089:
090:                Color background = getBackground();
091:                boolean colorMatch = (background != null)
092:                        && (background.equals(table.getBackground()))
093:                        && table.isOpaque();
094:                setOpaque(!colorMatch);
095:
096:                return this ;
097:            }
098:
099:            public void validate() {
100:            }
101:
102:            public void revalidate() {
103:            }
104:
105:            public void repaint(long tm, int x, int y, int width, int height) {
106:            }
107:
108:            public void repaint(Rectangle r) {
109:            }
110:
111:            protected void firePropertyChange(String propertyName,
112:                    Object oldValue, Object newValue) {
113:                if (propertyName == "text") {
114:                    super .firePropertyChange(propertyName, oldValue, newValue);
115:                }
116:            }
117:
118:            public void firePropertyChange(String propertyName,
119:                    boolean oldValue, boolean newValue) {
120:            }
121:
122:            private void setValue(Object value) {
123:                setText((value == null) ? "" : value.toString());
124:            }
125:
126:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.