Source Code Cross Referenced for EnhancedTableCellRenderer.java in  » Database-Client » iSQL-Viewer » org » isqlviewer » ui » laf » 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 » Database Client » iSQL Viewer » org.isqlviewer.ui.laf 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the Mozilla Public License
003:         * Version 1.1 (the "License"); you may not use this file except in
004:         * compliance with the License. You may obtain a copy of the License at
005:         * http://www.mozilla.org/MPL/
006:         *
007:         * Software distributed under the License is distributed on an "AS IS"
008:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
009:         * License for the specific language governing rights and limitations
010:         * under the License.
011:         * 
012:         * The Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
013:         *
014:         * The Initial Developer of the Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
015:         * Portions created by Mark A. Kobold are Copyright (C) 2000-2007. All Rights Reserved.
016:         *
017:         * Contributor(s): 
018:         *  Mark A. Kobold [mkobold <at> isqlviewer <dot> com].
019:         *  
020:         * If you didn't download this code from the following link, you should check
021:         * if you aren't using an obsolete version: http://www.isqlviewer.com
022:         */
023:        /*
024:         * A custom table cell renderer to simulate the look of cells in
025:         * Apple's brushed metal applications.
026:         * <p/>
027:         * Copyright (C) 2005 by Jon Lipsky
028:         * <p/>
029:         * Licensed under the Apache License, Version 2.0 (the "License");
030:         * you may not use this file except in compliance with the License. You may 
031:         * obtain a copy of the License at
032:         * <p/>
033:         * http://www.apache.org/licenses/LICENSE-2.0
034:         * <p/>
035:         * Unless required by applicable law or agreed to in writing, software d
036:         * istributed under the License is distributed on an "AS IS" BASIS,
037:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
038:         * See the License for the specific language governing permissions and
039:         * limitations under the License.
040:         */
041:        package org.isqlviewer.ui.laf;
042:
043:        import java.awt.Color;
044:        import java.awt.Component;
045:        import java.awt.Font;
046:
047:        import javax.swing.Icon;
048:        import javax.swing.JTable;
049:        import javax.swing.table.DefaultTableCellRenderer;
050:
051:        import org.isqlviewer.swing.SwingUtilities;
052:        import org.isqlviewer.swing.table.EnhancedTableModel;
053:
054:        /**
055:         * Modified version of the Aqua&cop; metal look and feel.
056:         * <p>
057:         * 
058:         * @author Jon Lipsky, Mark Kobold
059:         * @version 1.0
060:         */
061:        public class EnhancedTableCellRenderer extends DefaultTableCellRenderer {
062:
063:            private static final long serialVersionUID = -6332850927184223196L;
064:            public static final Color selectedFocusedColor = Color
065:                    .decode("#3D80DF");
066:            public static final Color selectedNotFocusedColor = Color
067:                    .decode("#C0C0C0");
068:            public static final Color evenRowColor = Color.decode("#EDF3FE");
069:            public static final Color oddRowColor = Color.WHITE;
070:            public static final Color gridColor = new Color(150, 150, 150);
071:
072:            // ------------------------------------------------------------------------------------------------------------------
073:            // Constructors and Getter/Setter methods
074:            // ------------------------------------------------------------------------------------------------------------------
075:            public EnhancedTableCellRenderer() {
076:
077:            }
078:
079:            public Icon getIcon(Object aObject) {
080:
081:                if (aObject == null) {
082:                    setHorizontalAlignment(CENTER);
083:                } else {
084:                    setHorizontalAlignment(LEFT);
085:                }
086:                return aObject == null ? SwingUtilities.loadIconResource(
087:                        "null_data", 16) : null;
088:            }
089:
090:            public String getText(Object aObject) {
091:
092:                return aObject == null ? null : aObject.toString();
093:            }
094:
095:            // ------------------------------------------------------------------------------------------------------------------
096:            // Overwridden methods from the superclass(es)
097:            // ------------------------------------------------------------------------------------------------------------------
098:            @Override
099:            public Component getTableCellRendererComponent(final JTable table,
100:                    Object value, boolean isSelected, boolean hasFocus,
101:                    final int row, int column) {
102:
103:                super .getTableCellRendererComponent(table, value, isSelected,
104:                        hasFocus, row, column);
105:                if (isSelected) {
106:                    if (table.hasFocus()) {
107:                        setBackground(selectedFocusedColor);
108:                        setForeground(Color.WHITE);
109:                    } else {
110:                        setBackground(selectedNotFocusedColor);
111:                        setForeground(Color.BLACK);
112:                    }
113:                } else {
114:                    Color color = row % 2 == 0 ? evenRowColor : oddRowColor;
115:                    setBackground(color);
116:                    setForeground(Color.BLACK);
117:                }
118:                setText(getText(value));
119:                setIcon(getIcon(value));
120:
121:                if (table.getModel() instanceof  EnhancedTableModel) {
122:                    EnhancedTableModel model = (EnhancedTableModel) table
123:                            .getModel();
124:                    Font fnt = table.getFont();
125:                    if (model.matchesFilter(row, column)) {
126:                        // increase the font by one point so we have size and hue for highlighting searches//
127:                        setFont(fnt.deriveFont(Font.BOLD, fnt.getSize2D() + 1f));
128:                    } else {
129:                        setFont(fnt);
130:                    }
131:                }
132:                return this;
133:            }
134:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.