Source Code Cross Referenced for CustomEtchedBorder.java in  » IDE » tIDE » snow » utils » gui » 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 » IDE » tIDE » snow.utils.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package snow.utils.gui;
002:
003:        import java.awt.*;
004:        import javax.swing.border.*;
005:        import javax.swing.UIManager;
006:
007:        /**
008:         *  Like MatteBorder, but with two lines. ( dark and bright usually )
009:         *  The effect from the two lines is like an etched border, but one
010:         *  can specify :
011:         *  on_top,on_left,on_bottom and on_right define if it should be painted at these locations.
012:         */
013:        public class CustomEtchedBorder extends EmptyBorder {
014:            protected Color lightColor;
015:            protected Color darkColor;
016:
017:            private boolean on_top;
018:            private boolean on_left;
019:            private boolean on_bottom;
020:            private boolean on_right;
021:
022:            boolean doUpdateColors = true; // on UI changes
023:
024:            /**
025:             *  Version with passed constant colors.
026:             */
027:            public CustomEtchedBorder(boolean on_top, boolean on_left,
028:                    boolean on_bottom, boolean on_right,
029:                    final Color lightColor, final Color darkColor) {
030:                super (on_top ? 2 : 0, on_left ? 2 : 0, on_bottom ? 2 : 0,
031:                        on_right ? 2 : 0);
032:                this .lightColor = lightColor;
033:                this .darkColor = darkColor;
034:                this .doUpdateColors = false; // dont change these colors on UI changes
035:                this .on_top = on_top;
036:                this .on_left = on_left;
037:                this .on_bottom = on_bottom;
038:                this .on_right = on_right;
039:            }
040:
041:            /**
042:             *  Version with automatically calculated colors, which then follow UI changes.
043:             */
044:            public CustomEtchedBorder(boolean on_top, boolean on_left,
045:                    boolean on_bottom, boolean on_right) {
046:                super (on_top ? 2 : 0, on_left ? 2 : 0, on_bottom ? 2 : 0,
047:                        on_right ? 2 : 0);
048:                this .lightColor = UIManager.getColor("Panel.background")
049:                        .brighter();
050:                this .darkColor = UIManager.getColor("Panel.background")
051:                        .darker();
052:                this .doUpdateColors = true; // follow on UI changes
053:                this .on_top = on_top;
054:                this .on_left = on_left;
055:                this .on_bottom = on_bottom;
056:                this .on_right = on_right;
057:            }
058:
059:            /**
060:             * Paints the matte border.
061:             */
062:            @Override
063:            public void paintBorder(Component c, Graphics g, int x, int y,
064:                    int width, int height) {
065:                if (this .doUpdateColors) {
066:                    this .lightColor = UIManager.getColor("Panel.background")
067:                            .brighter();
068:                    this .darkColor = UIManager.getColor("Panel.background")
069:                            .darker();
070:                }
071:
072:                Insets insets = getBorderInsets(c);
073:                Color oldColor = g.getColor();
074:                g.translate(x, y);
075:
076:                g.setColor(this .darkColor);
077:
078:                if (this .on_top)
079:                    g.drawLine(0, 0, width - 1, 0);
080:                if (this .on_left)
081:                    g.drawLine(0, 0, 0, height - 1);
082:                if (this .on_bottom)
083:                    g.drawLine(1, height - 2, width - 2, height - 2);
084:                if (this .on_right)
085:                    g.drawLine(width - 2, 1, width - 2, height - 2);
086:
087:                g.setColor(this .lightColor);
088:
089:                if (this .on_bottom)
090:                    g.drawLine(1, height - 1, width - 1, height - 1);
091:                if (this .on_right)
092:                    g.drawLine(width - 1, 1, width - 1, height - 1);
093:                if (this .on_top)
094:                    g.drawLine(1, 1, width - 2, 1);
095:                if (this .on_left)
096:                    g.drawLine(1, 1, 1, height - 2);
097:
098:                g.translate(-x, -y);
099:                g.setColor(oldColor);
100:            }
101:
102:            /**
103:             * Returns the insets of the border.
104:             * @param c the component for which this border insets value applies
105:             */
106:            @Override
107:            public Insets getBorderInsets(Component c) {
108:                return getBorderInsets();
109:            }
110:
111:            /**
112:             * Reinitialize the insets parameter with this Border's current Insets.
113:             * @param c the component for which this border insets value applies
114:             * @param insets the object to be reinitialized
115:             */
116:            @Override
117:            public Insets getBorderInsets(Component c, Insets insets) {
118:                return computeInsets(insets);
119:            }
120:
121:            /**
122:             * Returns the insets of the border.
123:             */
124:            @Override
125:            public Insets getBorderInsets() {
126:                return computeInsets(new Insets(0, 0, 0, 0));
127:            }
128:
129:            protected Insets computeInsets(Insets insets) {
130:                insets.left = left;
131:                insets.top = top;
132:                insets.right = right;
133:                insets.bottom = bottom;
134:                return insets;
135:            }
136:
137:            /**
138:             * @return whether or not the border is opaque.
139:             */
140:            @Override
141:            public boolean isBorderOpaque() {
142:                return true;
143:            }
144:
145:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.