Source Code Cross Referenced for View.java in  » Project-Management » borg » net » sf » borg » ui » 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 » Project Management » borg » net.sf.borg.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:        This file is part of BORG.
003:         
004:            BORG is free software; you can redistribute it and/or modify
005:            it under the terms of the GNU General Public License as published by
006:            the Free Software Foundation; either version 2 of the License, or
007:            (at your option) any later version.
008:         
009:            BORG is distributed in the hope that it will be useful,
010:            but WITHOUT ANY WARRANTY; without even the implied warranty of
011:            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012:            GNU General Public License for more details.
013:         
014:            You should have received a copy of the GNU General Public License
015:            along with BORG; if not, write to the Free Software
016:            Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         
018:        Copyright 2003 by Mike Berger
019:         */
020:        /*
021:         * View.java
022:         *
023:         * Created on May 23, 2003, 11:06 AM
024:         */
025:
026:        package net.sf.borg.ui;
027:
028:        import java.awt.Dimension;
029:        import java.awt.Frame;
030:        import java.awt.Image;
031:        import java.awt.Rectangle;
032:        import java.awt.Toolkit;
033:        import java.awt.event.ActionEvent;
034:        import java.awt.event.ActionListener;
035:        import java.awt.event.KeyEvent;
036:
037:        import javax.swing.JButton;
038:        import javax.swing.JComponent;
039:        import javax.swing.KeyStroke;
040:
041:        import net.sf.borg.common.PrefName;
042:        import net.sf.borg.common.Prefs;
043:        import net.sf.borg.model.Model;
044:
045:        /**
046:         * $Id: View.java 379 2005-09-10 07:12:16Z membar $
047:         * @author  MBERGER
048:         */
049:
050:        // Views show data from a model and respond to refresh
051:        // cand destroy allbacks from Models
052:        public abstract class View extends javax.swing.JFrame implements 
053:                Model.Listener {
054:            static Image image = Toolkit.getDefaultToolkit().getImage(
055:                    View.class.getResource("/resource/borg32x32.jpg"));
056:
057:            private PrefName prefName_ = null;
058:
059:            private void initialize() {
060:                setIconImage(image);
061:            }
062:
063:            public abstract void refresh();
064:
065:            public abstract void destroy();
066:
067:            public void remove() {
068:                destroy();
069:            }
070:
071:            public View() {
072:                initialize();
073:            }
074:
075:            private void recordSize(boolean resize) {
076:                String s = Prefs.getPref(prefName_);
077:                ViewSize vsnew = ViewSize.fromString(s);
078:
079:                if (!resize) {
080:                    // for a move, ignore the event if the size changes - this is
081:                    // part of a maximize or minimize and the resize will follow
082:                    if (vsnew.getHeight() != this .getBounds().height
083:                            || vsnew.getWidth() != this .getBounds().width)
084:                        return;
085:
086:                    // if x or y < 0, then this is likely the move before a maximize
087:                    // so ignore it
088:                    if (this .getBounds().x < 0 || this .getBounds().y < 0)
089:                        return;
090:
091:                    vsnew.setX(this .getBounds().x);
092:                    vsnew.setY(this .getBounds().y);
093:                    vsnew.setWidth(this .getBounds().width);
094:                    vsnew.setHeight(this .getBounds().height);
095:                } else if (this .getExtendedState() == Frame.MAXIMIZED_BOTH) {
096:                    vsnew.setMaximized(true);
097:                } else {
098:                    // only reset bounds if we are not maximized
099:                    vsnew.setMaximized(false);
100:                    vsnew.setX(this .getBounds().x);
101:                    vsnew.setY(this .getBounds().y);
102:                    vsnew.setWidth(this .getBounds().width);
103:                    vsnew.setHeight(this .getBounds().height);
104:
105:                }
106:
107:                //System.out.println(vsnew.toString());
108:                Prefs.putPref(this .prefName_, vsnew.toString());
109:
110:            }
111:
112:            // function to call to register a view with the model
113:            protected void addModel(Model m) {
114:                m.addListener(this );
115:            }
116:
117:            // called from the subclass to cause the View to use preferences to 
118:            // persist a View's size and locaiton if the user resizes it
119:            public void manageMySize(PrefName pname) {
120:                prefName_ = pname;
121:
122:                // set the initial size
123:                String s = Prefs.getPref(prefName_);
124:                ViewSize vs = ViewSize.fromString(s);
125:
126:                if (vs.getX() != -1) {
127:                    setBounds(new Rectangle(vs.getX(), vs.getY(),
128:                            vs.getWidth(), vs.getHeight()));
129:                } else if (vs.getWidth() != -1) {
130:                    setSize(new Dimension(vs.getWidth(), vs.getHeight()));
131:                }
132:                if (vs.isMaximized()) {
133:                    setExtendedState(Frame.MAXIMIZED_BOTH);
134:                }
135:                validate();
136:
137:                // add listeners to record any changes
138:                this 
139:                        .addComponentListener(new java.awt.event.ComponentAdapter() {
140:                            public void componentResized(
141:                                    java.awt.event.ComponentEvent e) {
142:                                //System.out.println("resize");
143:                                recordSize(true);
144:                            }
145:
146:                            public void componentMoved(
147:                                    java.awt.event.ComponentEvent e) {
148:                                //System.out.println("move");
149:                                recordSize(false);
150:                            }
151:                        });
152:            }
153:
154:            // protected //
155:            protected void setDismissButton(final JButton bn) {
156:                getLayeredPane().registerKeyboardAction(new ActionListener() {
157:                    public final void actionPerformed(ActionEvent e) {
158:                        bn.getActionListeners()[0].actionPerformed(e);
159:                    }
160:                }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
161:                        JComponent.WHEN_IN_FOCUSED_WINDOW);
162:            }
163:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.