Source Code Cross Referenced for XFramesetEditor.java in  » XML-UI » XUI » net » xoetrope » builder » editor » dialog » 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 » XML UI » XUI » net.xoetrope.builder.editor.dialog 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.xoetrope.builder.editor.dialog;
002:
003:        import java.awt.BorderLayout;
004:        import java.awt.Container;
005:        import java.awt.Dimension;
006:        import java.awt.event.ActionEvent;
007:        import java.awt.event.ActionListener;
008:        import java.awt.event.KeyEvent;
009:        import java.awt.event.KeyListener;
010:        import javax.swing.BorderFactory;
011:        import javax.swing.JDialog;
012:        import javax.swing.event.ChangeEvent;
013:        import javax.swing.event.ChangeListener;
014:
015:        import net.xoetrope.swing.XButton;
016:        import net.xoetrope.swing.XCheckbox;
017:        import net.xoetrope.swing.XEdit;
018:        import net.xoetrope.swing.XPanel;
019:        import net.xoetrope.xui.XPage;
020:        import net.xoetrope.xui.helper.BuddyHelper;
021:        import net.xoetrope.xui.style.XStyleFactory;
022:
023:        /**
024:         * A simple editor for a frameset
025:         * <p> Copyright (c) Xoetrope Ltd., 2002-2003</p>
026:         * <p> $Revision: 1.10 $</p>
027:         * <p> License: see License.txt</p>
028:         */
029:        public class XFramesetEditor extends JDialog implements  ChangeListener,
030:                ActionListener, KeyListener {
031:            private XButton btnOk, btnCancel;
032:            private boolean returnValue = false;
033:            private XEdit topEdit, leftEdit, centreEdit, rightEdit, bottomEdit;
034:            private XEdit topEditW, leftEditW, centreEditW, rightEditW,
035:                    bottomEditW;
036:            private XEdit topEditH, leftEditH, centreEditH, rightEditH,
037:                    bottomEditH;
038:            private XPanel topPanel, leftPanel, centrePanel, rightPanel,
039:                    bottomPanel;
040:            private XCheckbox topCheck, leftCheck, centreCheck, rightCheck,
041:                    bottomCheck;
042:            private String[] frameNames;
043:            private int pWidth, pHeight;
044:
045:            public XFramesetEditor(String[] frames, String[] sizes,
046:                    boolean showDimensions, int pageWidth, int pageHeight) {
047:                setModal(true);
048:                frameNames = frames;
049:                pWidth = pageWidth;
050:                pHeight = pageHeight;
051:
052:                setTitle("Frameset");
053:                setSize(438, 370);
054:
055:                getContentPane().setLayout(null);
056:                XStyleFactory factory = new XStyleFactory(
057:                        XPage.XUI_SWING_PACKAGE);
058:                Container contentPanel = getContentPane();
059:
060:                factory.setParentComponent(contentPanel);
061:                BuddyHelper buddy = new BuddyHelper(factory);
062:                XPanel mainPanel = (XPanel) factory.addComponent(XPage.PANEL,
063:                        5, 5, 425, 300, "");
064:                factory.setParentComponent(contentPanel);
065:                XPanel pnl = (XPanel) factory.addComponent(XPage.PANEL, 5, 305,
066:                        425, 40, "");
067:
068:                factory.setParentComponent(mainPanel);
069:                topPanel = (XPanel) factory.addComponent(XPage.PANEL, 5, 5,
070:                        410, 40, "");
071:                leftPanel = (XPanel) factory.addComponent(XPage.PANEL, 5, 50,
072:                        100, 200, "");
073:                centrePanel = (XPanel) factory.addComponent(XPage.PANEL, 110,
074:                        50, 200, 200, "");
075:                rightPanel = (XPanel) factory.addComponent(XPage.PANEL, 315,
076:                        50, 100, 200, "");
077:                bottomPanel = (XPanel) factory.addComponent(XPage.PANEL, 5,
078:                        255, 410, 40, "");
079:
080:                topPanel.setBorder(BorderFactory.createEtchedBorder());
081:                leftPanel.setBorder(BorderFactory.createEtchedBorder());
082:                centrePanel.setBorder(BorderFactory.createEtchedBorder());
083:                rightPanel.setBorder(BorderFactory.createEtchedBorder());
084:                bottomPanel.setBorder(BorderFactory.createEtchedBorder());
085:
086:                topPanel.setMinimumSize(new Dimension(10, 10));
087:                leftPanel.setMinimumSize(new Dimension(10, 10));
088:                centrePanel.setMinimumSize(new Dimension(10, 10));
089:                rightPanel.setMinimumSize(new Dimension(10, 10));
090:                bottomPanel.setMinimumSize(new Dimension(10, 10));
091:
092:                factory.setParentComponent(topPanel);
093:                topCheck = (XCheckbox) factory.addComponent(XPage.CHECK, 10,
094:                        10, 20, 20, "");
095:                topEdit = (XEdit) factory.addComponent(XPage.EDIT, 40, 10, 100,
096:                        20, frameNames[0]);
097:                int widthUsed = 0;
098:                int heightUsed = 0;
099:                if (showDimensions) {
100:                    topEditW = (XEdit) buddy.addComponent(XPage.EDIT, 150, 165,
101:                            10, 50, 20, "W:", Integer.toString(pWidth), null);
102:                    topEditH = (XEdit) buddy.addComponent(XPage.EDIT, 210, 225,
103:                            10, 50, 20, "H:", Integer.toString(pHeight / 5),
104:                            null);
105:                    topEditW.setEnabled(false);
106:                    topEditH.addKeyListener(this );
107:                    heightUsed += pHeight / 5;
108:                }
109:                topCheck.addChangeListener(this );
110:
111:                factory.setParentComponent(bottomPanel);
112:                bottomCheck = (XCheckbox) factory.addComponent(XPage.CHECK, 10,
113:                        10, 20, 20, "");
114:                bottomEdit = (XEdit) factory.addComponent(XPage.EDIT, 40, 10,
115:                        100, 20, frameNames[4]);
116:                bottomCheck.addChangeListener(this );
117:                if (showDimensions) {
118:                    bottomEditW = (XEdit) buddy.addComponent(XPage.EDIT, 150,
119:                            165, 10, 50, 20, "W:", Integer.toString(pWidth),
120:                            null);
121:                    bottomEditH = (XEdit) buddy.addComponent(XPage.EDIT, 210,
122:                            225, 10, 50, 20, "H:", Integer
123:                                    .toString(pHeight / 5), null);
124:                    bottomEditW.setEnabled(false);
125:                    bottomEditH.addKeyListener(this );
126:                    heightUsed += pHeight / 5;
127:                }
128:
129:                factory.setParentComponent(leftPanel);
130:                leftCheck = (XCheckbox) factory.addComponent(XPage.CHECK, 10,
131:                        50, 20, 20, "");
132:                leftEdit = (XEdit) factory.addComponent(XPage.EDIT, 10, 80, 80,
133:                        20, frameNames[1]);
134:                if (showDimensions) {
135:                    leftEditW = (XEdit) buddy.addComponent(XPage.EDIT, 10, 25,
136:                            110, 50, 20, "W:", "140", null);
137:                    leftEditH = (XEdit) buddy.addComponent(XPage.EDIT, 10, 25,
138:                            140, 50, 20, "H:", Integer.toString(pHeight / 5),
139:                            null);
140:                    leftEditW.setEnabled(false);
141:                    leftEditH.setEnabled(false);
142:                    leftEditW.addKeyListener(this );
143:                    widthUsed += pWidth / 5;
144:                }
145:                leftCheck.addChangeListener(this );
146:
147:                factory.setParentComponent(rightPanel);
148:                rightCheck = (XCheckbox) factory.addComponent(XPage.CHECK, 10,
149:                        50, 20, 20, "");
150:                rightEdit = (XEdit) factory.addComponent(XPage.EDIT, 10, 80,
151:                        80, 20, frameNames[3]);
152:                if (showDimensions) {
153:                    rightEditW = (XEdit) buddy.addComponent(XPage.EDIT, 10, 25,
154:                            110, 50, 20, "W:", "140", null);
155:                    rightEditH = (XEdit) buddy.addComponent(XPage.EDIT, 10, 25,
156:                            140, 50, 20, "H:", Integer.toString(pHeight / 5),
157:                            null);
158:                    rightEditW.setEnabled(false);
159:                    rightEditH.setEnabled(false);
160:                    rightEditW.addKeyListener(this );
161:                    widthUsed += pWidth / 5;
162:                }
163:                rightCheck.addChangeListener(this );
164:
165:                factory.setParentComponent(centrePanel);
166:                centreCheck = (XCheckbox) factory.addComponent(XPage.CHECK, 10,
167:                        50, 20, 20, "");
168:                centreEdit = (XEdit) factory.addComponent(XPage.EDIT, 10, 80,
169:                        100, 20, frameNames[2]);
170:                if (showDimensions) {
171:                    centreEditW = (XEdit) buddy.addComponent(XPage.EDIT, 10,
172:                            25, 110, 50, 20, "W:", Integer.toString(pWidth),
173:                            null);
174:                    centreEditH = (XEdit) buddy.addComponent(XPage.EDIT, 10,
175:                            25, 140, 50, 20, "H:", Integer
176:                                    .toString(pHeight / 5), null);
177:                    centreEditW.setEnabled(false);
178:                    centreEditH.setEnabled(false);
179:                }
180:                centreCheck.setEnabled(false);
181:                centreCheck.setSelected(true);
182:                centreEdit.setEnabled(false);
183:
184:                mainPanel.add(topPanel, BorderLayout.NORTH);
185:                mainPanel.add(leftPanel, BorderLayout.WEST);
186:                mainPanel.add(centrePanel, BorderLayout.CENTER);
187:                mainPanel.add(rightPanel, BorderLayout.EAST);
188:                mainPanel.add(bottomPanel, BorderLayout.SOUTH);
189:                mainPanel.doLayout();
190:
191:                factory.setParentComponent(pnl);
192:                btnCancel = (XButton) factory.addComponent(XPage.BUTTON, 215,
193:                        0, 95, 20, "Cancel");
194:                btnOk = (XButton) factory.addComponent(XPage.BUTTON, 320, 0,
195:                        95, 20, "OK");
196:                btnOk.addActionListener(this );
197:                btnCancel.addActionListener(this );
198:
199:                if (frameNames[0].length() > 0) {
200:                    topCheck.setSelected(true);
201:                    topEdit.setEnabled(true);
202:                }
203:                if (frameNames[1].length() > 0) {
204:                    leftCheck.setSelected(true);
205:                    leftEdit.setEnabled(true);
206:                }
207:                if (frameNames[3].length() > 0) {
208:                    rightCheck.setSelected(true);
209:                    rightEdit.setEnabled(true);
210:                }
211:                if (frameNames[4].length() > 0) {
212:                    bottomCheck.setSelected(true);
213:                    bottomEdit.setEnabled(true);
214:                }
215:
216:                setFrameSize(sizes);
217:            }
218:
219:            public void actionPerformed(ActionEvent e) {
220:                Object source = e.getSource();
221:                if (source == btnOk) {
222:                    returnValue = true;
223:                    if (!topCheck.isSelected())
224:                        frameNames[0] = "";
225:                    else
226:                        frameNames[0] = topEdit.getText();
227:
228:                    if (!leftCheck.isSelected())
229:                        frameNames[1] = "";
230:                    else
231:                        frameNames[1] = leftEdit.getText();
232:
233:                    if (!rightCheck.isSelected())
234:                        frameNames[3] = "";
235:                    else
236:                        frameNames[3] = rightEdit.getText();
237:
238:                    if (!bottomCheck.isSelected())
239:                        frameNames[4] = "";
240:                    else
241:                        frameNames[4] = bottomEdit.getText();
242:                    hide();
243:                } else if (source == btnCancel) {
244:                    returnValue = false;
245:                    hide();
246:                }
247:            }
248:
249:            public void stateChanged(ChangeEvent e) {
250:                Object source = e.getSource();
251:                boolean state = ((XCheckbox) source).isSelected();
252:                if (source == topCheck) {
253:                    topEdit.setEnabled(state);
254:                    topEditH.setEnabled(state);
255:                } else if (source == leftCheck) {
256:                    leftEdit.setEnabled(state);
257:                    leftEditW.setEnabled(state);
258:                } else if (source == rightCheck) {
259:                    rightEdit.setEnabled(state);
260:                    rightEditW.setEnabled(state);
261:                } else if (source == bottomCheck) {
262:                    bottomEdit.setEnabled(state);
263:                    bottomEditH.setEnabled(state);
264:                }
265:                calcSizes();
266:            }
267:
268:            public String[] getFrameNames() {
269:                return frameNames;
270:            }
271:
272:            public boolean getResult() {
273:                return returnValue;
274:            }
275:
276:            public void calcSizes() {
277:                try {
278:                    int widthUsed = 0;
279:                    int heightUsed = 0;
280:                    if (topCheck.isSelected()
281:                            && (topEditH.getText().length() > 0)) {
282:                        heightUsed += Integer.parseInt(topEditH.getText());
283:                    }
284:                    if (bottomCheck.isSelected()
285:                            && (bottomEditH.getText().length() > 0)) {
286:                        heightUsed += Integer.parseInt(bottomEditH.getText());
287:                    }
288:                    if (leftCheck.isSelected()
289:                            && (leftEditW.getText().length() > 0)) {
290:                        widthUsed += Integer.parseInt(leftEditW.getText());
291:                    }
292:                    if (rightCheck.isSelected()
293:                            && (rightEditW.getText().length() > 0)) {
294:                        widthUsed += Integer.parseInt(rightEditW.getText());
295:                    }
296:                    centreEditW.setText(Integer.toString(pWidth - widthUsed));
297:                    centreEditH.setText(Integer.toString(pHeight - heightUsed));
298:                    leftEditH.setText(Integer.toString(pHeight - heightUsed));
299:                    rightEditH.setText(Integer.toString(pHeight - heightUsed));
300:                } catch (NumberFormatException ex) {
301:                }
302:            }
303:
304:            public String[] getFrameSizes() {
305:                String sizes[] = new String[10];
306:                sizes[0] = topEditW.getText();
307:                sizes[1] = topEditH.getText();
308:                sizes[2] = leftEditW.getText();
309:                sizes[3] = leftEditH.getText();
310:                sizes[4] = centreEditW.getText();
311:                sizes[5] = centreEditH.getText();
312:                sizes[6] = rightEditW.getText();
313:                sizes[7] = rightEditH.getText();
314:                sizes[8] = bottomEditW.getText();
315:                sizes[9] = bottomEditH.getText();
316:
317:                return sizes;
318:            }
319:
320:            public void setFrameSize(String[] sizes) {
321:                if (sizes != null) {
322:                    topEditW.setText(sizes[0]);
323:                    topEditH.setText(sizes[1]);
324:                    leftEditW.setText(sizes[2]);
325:                    leftEditH.setText(sizes[3]);
326:                    centreEditW.setText(sizes[4]);
327:                    centreEditH.setText(sizes[5]);
328:                    rightEditW.setText(sizes[6]);
329:                    rightEditH.setText(sizes[7]);
330:                    bottomEditW.setText(sizes[8]);
331:                    bottomEditH.setText(sizes[9]);
332:                }
333:            }
334:
335:            /**
336:             * Invoked when a key has been typed.
337:             * See the class description for {@link KeyEvent} for a definition of
338:             * a key typed event.
339:             */
340:            public void keyTyped(KeyEvent e) {
341:            }
342:
343:            /**
344:             * Invoked when a key has been pressed.
345:             * See the class description for {@link KeyEvent} for a definition of
346:             * a key pressed event.
347:             */
348:            public void keyPressed(KeyEvent e) {
349:            }
350:
351:            /**
352:             * Invoked when a key has been released.
353:             * See the class description for {@link KeyEvent} for a definition of
354:             * a key released event.
355:             */
356:            public void keyReleased(KeyEvent e) {
357:                calcSizes();
358:            }
359:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.