Source Code Cross Referenced for ComponentFactory.java in  » UML » jrefactory » org » acm » seguin » pmd » swingui » 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 » UML » jrefactory » org.acm.seguin.pmd.swingui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.acm.seguin.pmd.swingui;
002:
003:        import javax.swing.JButton;
004:        import javax.swing.JPanel;
005:        import javax.swing.JScrollPane;
006:        import javax.swing.JSplitPane;
007:        import javax.swing.JTextArea;
008:        import javax.swing.UIManager;
009:        import javax.swing.border.BevelBorder;
010:        import javax.swing.border.CompoundBorder;
011:        import javax.swing.border.EmptyBorder;
012:        import javax.swing.border.EtchedBorder;
013:        import javax.swing.border.LineBorder;
014:        import javax.swing.border.TitledBorder;
015:        import java.awt.Color;
016:        import java.awt.Component;
017:        import java.awt.Dimension;
018:        import java.awt.FlowLayout;
019:        import java.awt.Toolkit;
020:        import java.awt.event.ActionListener;
021:
022:        /**
023:         *
024:         * @author Donald A. Leckie
025:         * @since August 29, 2002
026:         * @version $Revision: 1.1 $, $Date: 2003/07/29 20:51:59 $
027:         */
028:        class ComponentFactory {
029:
030:            /**
031:             ******************************************************************************
032:             *
033:             * @return
034:             */
035:            protected static final JPanel createButtonPanel() {
036:                JPanel buttonPanel = new JPanel(new FlowLayout(
037:                        FlowLayout.CENTER));
038:                EmptyBorder emptyBorder = new EmptyBorder(3, 3, 3, 3);
039:                EtchedBorder etchedBorder = new EtchedBorder(
040:                        EtchedBorder.RAISED);
041:                CompoundBorder compoundBorder = new CompoundBorder(
042:                        etchedBorder, emptyBorder);
043:                buttonPanel.setBorder(compoundBorder);
044:
045:                return buttonPanel;
046:            }
047:
048:            /**
049:             ******************************************************************************
050:             *
051:             * @param title
052:             *
053:             * @return
054:             */
055:            protected static final JButton createButton(String title) {
056:                return createButton(title, null, null);
057:            }
058:
059:            /**
060:             ******************************************************************************
061:             *
062:             * @param title
063:             *
064:             * @return
065:             */
066:            protected static final JButton createButton(String title,
067:                    Color background, Color foreground) {
068:                JButton button;
069:                BevelBorder bevelBorder;
070:                EtchedBorder etchedBorder;
071:                CompoundBorder compoundBorder;
072:                LineBorder lineBorder;
073:                Dimension size;
074:
075:                if (background == null) {
076:                    background = UIManager.getColor("standardButtonBackground");
077:                }
078:
079:                if (foreground == null) {
080:                    foreground = UIManager.getColor("standardButtonForeground");
081:                }
082:
083:                button = new JButton(title);
084:                lineBorder = new LineBorder(Color.DARK_GRAY, 1, true);
085:                bevelBorder = new BevelBorder(BevelBorder.RAISED);
086:                compoundBorder = new CompoundBorder(bevelBorder, lineBorder);
087:                etchedBorder = new EtchedBorder(EtchedBorder.LOWERED);
088:                compoundBorder = new CompoundBorder(etchedBorder,
089:                        compoundBorder);
090:                compoundBorder = new CompoundBorder(lineBorder, compoundBorder);
091:                size = new Dimension(80, 30);
092:
093:                button.setBackground(background);
094:                button.setForeground(foreground);
095:                button.setBorder(compoundBorder);
096:                button.setFont(UIManager.getFont("buttonFont"));
097:                button.setSize(size);
098:                button.setPreferredSize(size);
099:                button.setOpaque(true);
100:
101:                return button;
102:            }
103:
104:            /**
105:             *******************************************************************************
106:             *
107:             */
108:            protected static final JButton createSaveButton(
109:                    ActionListener actionListener) {
110:                Color background = UIManager.getColor("pmdGreen");
111:                Color foreground = Color.white;
112:                JButton saveButton = ComponentFactory.createButton("Save",
113:                        background, foreground);
114:                saveButton.addActionListener(actionListener);
115:
116:                return saveButton;
117:            }
118:
119:            /**
120:             *******************************************************************************
121:             *
122:             */
123:            protected static final JButton createCancelButton(
124:                    ActionListener actionListener) {
125:                Color background = UIManager.getColor("pmdRed");
126:                Color foreground = Color.white;
127:                JButton cancelButton = ComponentFactory.createButton("Cancel",
128:                        background, foreground);
129:                cancelButton.addActionListener(actionListener);
130:
131:                return cancelButton;
132:            }
133:
134:            /**
135:             *******************************************************************************
136:             *
137:             */
138:            protected static final JPanel createSaveCancelButtonPanel(
139:                    ActionListener saveActionListener,
140:                    ActionListener cancelActionListener) {
141:                JPanel buttonPanel = createButtonPanel();
142:                buttonPanel.add(createSaveButton(saveActionListener));
143:                buttonPanel.add(createCancelButton(cancelActionListener));
144:
145:                return buttonPanel;
146:            }
147:
148:            /**
149:             ******************************************************************************
150:             *
151:             * @param title
152:             *
153:             * @return
154:             */
155:            protected static final TitledBorder createTitledBorder(String title) {
156:                TitledBorder titledBorder;
157:                EtchedBorder etchedBorder;
158:                CompoundBorder compoundBorder;
159:
160:                etchedBorder = new EtchedBorder(EtchedBorder.LOWERED);
161:                compoundBorder = new CompoundBorder(etchedBorder, etchedBorder);
162:                titledBorder = new TitledBorder(compoundBorder, title);
163:
164:                titledBorder.setTitleFont(UIManager.getFont("titleFont"));
165:                titledBorder.setTitleColor(UIManager.getColor("pmdBlue"));
166:                titledBorder.setTitleJustification(TitledBorder.LEFT);
167:
168:                return titledBorder;
169:            }
170:
171:            /**
172:             ******************************************************************************
173:             *
174:             * @param view
175:             *
176:             * @return
177:             */
178:            protected static final JSplitPane createHorizontalSplitPane(
179:                    Component leftPane, Component rightPane) {
180:                JSplitPane splitPane = new JSplitPane();
181:
182:                splitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
183:                splitPane.setResizeWeight(0.5);
184:                splitPane.setDividerSize(10);
185:                splitPane.setLeftComponent(leftPane);
186:                splitPane.setRightComponent(rightPane);
187:                splitPane.setOpaque(true);
188:
189:                return splitPane;
190:            }
191:
192:            /**
193:             ******************************************************************************
194:             *
195:             * @param view
196:             *
197:             * @return
198:             */
199:            protected static final JSplitPane createVerticalSplitPane(
200:                    Component topPane, Component bottomPane) {
201:                JSplitPane splitPane = new JSplitPane();
202:
203:                splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
204:                splitPane.setResizeWeight(0.5);
205:                splitPane.setDividerSize(10);
206:                splitPane.setTopComponent(topPane);
207:                splitPane.setBottomComponent(bottomPane);
208:                splitPane.setOpaque(true);
209:
210:                return splitPane;
211:            }
212:
213:            /**
214:             ******************************************************************************
215:             *
216:             * @param view
217:             *
218:             * @return
219:             */
220:            protected static final JScrollPane createScrollPane(Component view) {
221:                JScrollPane scrollPane = new JScrollPane(view);
222:
223:                scrollPane
224:                        .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
225:                scrollPane
226:                        .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
227:                scrollPane.getViewport().setBackground(Color.white);
228:                scrollPane.setAutoscrolls(true);
229:                scrollPane.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
230:
231:                return scrollPane;
232:            }
233:
234:            /**
235:             ******************************************************************************
236:             *
237:             * @return
238:             */
239:            protected static final JTextArea createTextArea(String text) {
240:                JTextArea textArea;
241:                BevelBorder bevelBorder;
242:                EmptyBorder emptyBorder;
243:                CompoundBorder compoundBorder;
244:
245:                textArea = new JTextArea(text);
246:                bevelBorder = new BevelBorder(BevelBorder.LOWERED);
247:                emptyBorder = new EmptyBorder(3, 3, 3, 3);
248:                compoundBorder = new CompoundBorder(bevelBorder, emptyBorder);
249:
250:                textArea.setFont(UIManager.getFont("dataFont"));
251:                textArea.setBackground(Color.white);
252:                textArea.setLineWrap(true);
253:                textArea.setWrapStyleWord(true);
254:                textArea.setBorder(compoundBorder);
255:                textArea.setOpaque(true);
256:
257:                return textArea;
258:            }
259:
260:            /**
261:             *******************************************************************************
262:             *
263:             * @param windowWidth
264:             * @param windowHeight
265:             */
266:            protected static final Dimension adjustWindowSize(int windowWidth,
267:                    int windowHeight) {
268:                Dimension screenSize = Toolkit.getDefaultToolkit()
269:                        .getScreenSize();
270:
271:                if (windowWidth >= screenSize.width) {
272:                    windowWidth = screenSize.width - 10;
273:                }
274:
275:                if (windowHeight >= screenSize.height) {
276:                    windowHeight = screenSize.height - 20;
277:                }
278:
279:                return new Dimension(windowWidth, windowHeight);
280:            }
281:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.