Source Code Cross Referenced for BorderedPanel.java in  » Development » jrc-editor » org » zaval » awt » 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 » Development » jrc editor » org.zaval.awt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *     Caption: Zaval Java Resource Editor
003:         *     $Revision: 0.37 $
004:         *     $Date: 2002/03/28 9:24:42 $
005:         *
006:         *     @author:     Victor Krapivin
007:         *     @version:    1.3
008:         *
009:         * Zaval JRC Editor is a visual editor which allows you to manipulate 
010:         * localization strings for all Java based software with appropriate 
011:         * support embedded.
012:         * 
013:         * For more info on this product read Zaval Java Resource Editor User's Guide
014:         * (It comes within this package).
015:         * The latest product version is always available from the product's homepage:
016:         * http://www.zaval.org/products/jrc-editor/
017:         * and from the SourceForge:
018:         * http://sourceforge.net/projects/zaval0002/
019:         *
020:         * Contacts:
021:         *   Support : support@zaval.org
022:         *   Change Requests : change-request@zaval.org
023:         *   Feedback : feedback@zaval.org
024:         *   Other : info@zaval.org
025:         * 
026:         * Copyright (C) 2001-2002  Zaval Creative Engineering Group (http://www.zaval.org)
027:         * 
028:         * This program is free software; you can redistribute it and/or
029:         * modify it under the terms of the GNU General Public License
030:         * (version 2) as published by the Free Software Foundation.
031:         * 
032:         * This program is distributed in the hope that it will be useful,
033:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
034:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
035:         * GNU General Public License for more details.
036:         * 
037:         * You should have received a copy of the GNU General Public License
038:         * along with this program; if not, write to the Free Software
039:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
040:         * 
041:         */package org.zaval.awt;
042:
043:        import java.awt.*;
044:
045:        public class BorderedPanel extends Panel {
046:            public static final int NONE = 0;
047:            public static final int RAISED = 1;
048:            public static final int SUNKEN = 2;
049:            public static final int ETCHED = 3;
050:            public static final int RAISED2 = 4;
051:
052:            protected int type = RAISED;
053:            protected int hideMode = 0;
054:            protected Insets insets = new Insets(2, 2, 2, 2);
055:            protected static Color[] colors = { Color.white, Color.gray };
056:
057:            public BorderedPanel() {
058:                this (ETCHED);
059:            }
060:
061:            public BorderedPanel(int type) {
062:                this .type = type;
063:            }
064:
065:            public void setType(int t) {
066:                if (type == t)
067:                    return;
068:                type = t;
069:                repaint();
070:            }
071:
072:            public void setHideMode(int m) {
073:                if (hideMode == m)
074:                    return;
075:                hideMode = m;
076:            }
077:
078:            public Insets getInsets() {
079:                return insets;
080:            }
081:
082:            /*    public Insets insets() {
083:             return insets;
084:             }*/
085:
086:            public void paint(Graphics g) {
087:                // System.err.println("+++ " + this + ": " + (type == NONE?"NONE":"VISIBLE"));
088:                // this.list(System.err,0);
089:                if (type == NONE) {
090:                    Rectangle r = bounds();
091:                    g.setColor(getParent().getBackground());
092:                    g.fillRect(0, 0, r.width, r.height);
093:                    return;
094:                }
095:                super .paint(g);
096:
097:                Dimension d = size();
098:                int x = 0;
099:                int y = 0;
100:                int x2 = d.width - 1;// - 2;
101:                int y2 = d.height - 1;// - 2;
102:
103:                leftLine(g, x, y, x2, y2);
104:                rightLine(g, x, y, x2, y2);
105:
106:                topLine(g, x, y, x2, y2);
107:                bottomLine(g, x, y, x2, y2);
108:            }
109:
110:            public void leftLine(Graphics g, int x, int y, int x2, int y2) {
111:                g.setColor(colors[1]);
112:                switch (type) {
113:                case ETCHED: {
114:                    g.setColor(colors[1]);
115:                    g.drawLine(x, y, x, y2 - 1); // Topleft to bottomleft
116:                    g.setColor(colors[0]);
117:                    g.drawLine(x + 1, y + 1, x + 1, y2 - 2); // Topleft to bottomleft
118:                }
119:                    break;
120:                case RAISED2: {
121:                    g.setColor(colors[0]);
122:                    g.drawLine(x, y, x, y2 + 2); // Topleft to bottomleft
123:                }
124:                    break;
125:                case RAISED: {
126:                    g.setColor(colors[0]);
127:
128:                    g.drawLine(x, y, x, y2 - 1); // Topleft to bottomleft
129:                }
130:                    break;
131:                case SUNKEN: {
132:                    g.setColor(colors[1]);
133:                    g.drawLine(x, y, x, y2 - 1); // Topleft to bottomleft
134:                    g.setColor(Color.black);
135:                    g.drawLine(x + 1, y + 1, x + 1, y2 - 2); // Topleft to bottomleft
136:                }
137:                }
138:            }
139:
140:            public void rightLine(Graphics g, int x, int y, int x2, int y2) {
141:                g.setColor(colors[1]);
142:                switch (type) {
143:                case ETCHED: {
144:                    g.setColor(colors[1]);
145:                    g.drawLine(x2 - 1, y + 1, x2 - 1, y2); // Topright to bottomright
146:                    g.setColor(colors[0]);
147:                    g.drawLine(x2, y, x2, y2); // Topright to bottomright
148:                }
149:                    break;
150:                case RAISED: {
151:                    g.setColor(colors[1]);
152:                    g.drawLine(x2, y, x2, y2); // Topright to bottomright
153:                    g.setColor(colors[1]);
154:                    g.drawLine(x2 - 1, y + 1, x2 - 1, y2 - 1); // Topright to bottomright
155:                }
156:                    break;
157:                case SUNKEN: {
158:                    g.setColor(colors[0]);
159:                    g.drawLine(x2, y, x2, y2 - 1); // Topright to bottomright
160:                    //  g.drawLine(x2 - 1, y+1, x2 - 1, y2 - 1);  // Topright to bottomright
161:                }
162:                    break;
163:                case RAISED2:
164:                    g.setColor(colors[1]);
165:                    g.drawLine(x2, y, x2, y2); // Topright to bottomright
166:                    break;
167:                }
168:            }
169:
170:            public void topLine(Graphics g, int x, int y, int x2, int y2) {
171:                g.setColor(colors[1]);
172:                switch (type) {
173:                case ETCHED: {
174:                    g.setColor(colors[1]);
175:                    g.drawLine(x, y, x2 - 1, y); // Topleft to topright
176:                    g.setColor(colors[0]);
177:                    g.drawLine(x + 1, y + 1, x2 - 2, y + 1); // Topleft to topright
178:                }
179:                    break;
180:                case RAISED2: {
181:                    g.setColor(colors[0]);
182:                    g.drawLine(x, y, x2 + 2, y); // Topleft to topright
183:                }
184:                    break;
185:                case RAISED: {
186:                    g.setColor(colors[0]);
187:                    g.drawLine(x, y, x2 - 1, y); // Topleft to topright*/
188:                }
189:                    break;
190:                case SUNKEN: {
191:                    g.setColor(Color.black);
192:                    g.drawLine(x + 1, y + 1, x2 - 2, y + 1); // Topleft to topright
193:                    g.setColor(colors[1]);
194:                    g.drawLine(x, y, x2 - 1, y); // Topleft to topright
195:                }
196:                }
197:            }
198:
199:            public void bottomLine(Graphics g, int x, int y, int x2, int y2) {
200:                g.setColor(colors[1]);
201:                switch (type) {
202:                case ETCHED: {
203:                    g.setColor(colors[1]);
204:                    g.drawLine(x, y2 - 1, x2 - 1, y2 - 1); // Bottomleft to bottomright
205:                    g.setColor(colors[0]);
206:                    g.drawLine(x, y2, x2, y2); // Bottomleft to bottomright
207:                }
208:                    break;
209:                case RAISED: {
210:                    g.setColor(colors[1]);
211:                    g.drawLine(x, y2, x2 - 1, y2); // Bottomleft to bottomright
212:                    g.setColor(colors[1]);
213:                    g.drawLine(x + 1, y2 - 1, x2 - 2, y2 - 1); // Bottomleft to bottomright
214:                }
215:                    break;
216:                case SUNKEN: {
217:                    g.setColor(colors[0]);
218:                    g.drawLine(x, y2, x2, y2); // Bottomleft to bottomright
219:                    g.drawLine(x + 1, y2 - 1, x2 - 1, y2 - 1); // Bottomleft to bottomright
220:                }
221:                    break;
222:                case RAISED2:
223:                    g.setColor(colors[1]);
224:                    g.drawLine(x + 1, y2, x2, y2); // Bottomleft to bottomright
225:                    break;
226:                }
227:            }
228:
229:            int prevMode = -1;
230:
231:            public void hide() {
232:                //System.err.println("--- " + this + ": " + type + "/" + prevMode);
233:                if (hideMode == 0)
234:                    super .hide();
235:                else {
236:                    if (type == NONE)
237:                        return;
238:                    prevMode = type;
239:                    setType(NONE);
240:                }
241:            }
242:
243:            public boolean isVisible() {
244:                if (hideMode == 0)
245:                    return super .isVisible();
246:                if (type == NONE)
247:                    return false;
248:                return true;
249:            }
250:
251:            public void show() {
252:                // System.err.println("*** " + this + ": " + type + "/" + prevMode);
253:                if (hideMode == 0)
254:                    super .show();
255:                else {
256:                    if (!super .isVisible())
257:                        super .show();
258:                    if (prevMode < 0)
259:                        return;
260:                    setType(prevMode);
261:                    prevMode = -1;
262:                    //    System.err.println("*** " + this + ": VALIDATE as " + type + "/" + prevMode);
263:                    try {
264:                        super .hide();
265:                        super .show();
266:                        ((Component) this ).invalidate();
267:                        ((Component) this ).validate();
268:                        repaint();
269:                    } catch (Exception e) {
270:                        e.printStackTrace();
271:                    }
272:                }
273:            }
274:
275:            // X11 fixes to avoid wrong repaints
276:            public boolean mouseMove(Event e, int x, int y) {
277:                return true;
278:            }
279:
280:            public boolean mouseExit(Event e, int x, int y) {
281:                return true;
282:            }
283:
284:            public boolean mouseEnter(Event e, int x, int y) {
285:                return true;
286:            }
287:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.