Source Code Cross Referenced for FontDialogSwing.java in  » Database-DBMS » hsql » org » hsqldb » util » 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 » Database DBMS » hsql » org.hsqldb.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright (c) 2001-2005, The HSQL Development Group
002:         * All rights reserved.
003:         *
004:         * Redistribution and use in source and binary forms, with or without
005:         * modification, are permitted provided that the following conditions are met:
006:         *
007:         * Redistributions of source code must retain the above copyright notice, this
008:         * list of conditions and the following disclaimer.
009:         *
010:         * Redistributions in binary form must reproduce the above copyright notice,
011:         * this list of conditions and the following disclaimer in the documentation
012:         * and/or other materials provided with the distribution.
013:         *
014:         * Neither the name of the HSQL Development Group nor the names of its
015:         * contributors may be used to endorse or promote products derived from this
016:         * software without specific prior written permission.
017:         *
018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020:         * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
021:         * ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,
022:         * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
023:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
024:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
025:         * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
026:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
027:         * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
028:         * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029:         */
030:
031:        package org.hsqldb.util;
032:
033:        import java.awt.Color;
034:        import java.awt.Container;
035:        import java.awt.Dimension;
036:        import java.awt.FlowLayout;
037:        import java.awt.Font;
038:        import java.awt.GraphicsEnvironment;
039:        import java.awt.event.ActionEvent;
040:        import java.awt.event.ActionListener;
041:        import java.awt.event.ItemEvent;
042:        import java.awt.event.ItemListener;
043:
044:        import javax.swing.ImageIcon;
045:        import javax.swing.JButton;
046:        import javax.swing.JCheckBox;
047:        import javax.swing.JColorChooser;
048:        import javax.swing.JComboBox;
049:        import javax.swing.JDialog;
050:        import javax.swing.JFrame;
051:
052:        //  weconsultants@users 20041109 - original swing port
053:        //  weconsultants@users 20050215 - version 1.8.0 -  Update: Compatbilty fix for JDK 1.3
054:        //      - Replaced: Objects JSpinner spinnerFontSizes and SpinnerNumberModel spinnerModelSizes
055:        //        for JComboBox fontSizesComboBox and String fontSizes[];
056:        public class FontDialogSwing extends JDialog {
057:
058:            private static boolean isRunning = false;
059:            private static final String BACKGROUND = "Background";
060:            private static String defaultFont = "Dialog";
061:            private static final String FOREGROUND = "Foreground";
062:            private static JButton bgColorButton;
063:            private static JCheckBox ckbbold;
064:            private static JButton closeButton;
065:            private static JButton fgColorButton;
066:            private static JComboBox fontsComboBox;
067:
068:            //  weconsultants@users 20050215 - Added for Compatbilty fix for JDK 1.3
069:            private static JComboBox fontSizesComboBox;
070:            private static final String[] fontSizes = { "8", "9", "10", "11",
071:                    "12", "13", "14", "16", "18", "24", "36" };
072:
073:            // weconsultants@users 20050215 - Commented out for Compatbilty fix for JDK 1.3
074:            //  private static JSpinner           spinnerFontSizes;
075:            //  private static SpinnerNumberModel spinnerModelSizes;
076:            private static DatabaseManagerSwing fOwner;
077:            private static JFrame frame = new JFrame(
078:                    "DataBaseManagerSwing Font Selection Dialog");
079:            private static JCheckBox ckbitalic;
080:
081:            /**
082:             * Create and display FontDialogSwing Dialog.
083:             *
084:             */
085:            public static void CreatFontDialog(DatabaseManagerSwing owner) {
086:
087:                if (isRunning) {
088:                    frame.setVisible(true);
089:                } else {
090:                    CommonSwing.setSwingLAF(frame, CommonSwing.Native);
091:
092:                    fOwner = owner;
093:
094:                    frame.setIconImage(CommonSwing.getIcon("Frame"));
095:
096:                    isRunning = true;
097:
098:                    frame.setSize(600, 100);
099:                    CommonSwing.setFramePositon(frame);
100:
101:                    ckbitalic = new JCheckBox(new ImageIcon(CommonSwing
102:                            .getIcon("ItalicFont")));
103:
104:                    ckbitalic.putClientProperty("is3DEnabled", Boolean.TRUE);
105:                    ckbitalic.addActionListener(new ActionListener() {
106:
107:                        public void actionPerformed(ActionEvent e) {
108:                            setStyle();
109:                        }
110:                    });
111:
112:                    ckbbold = new JCheckBox(new ImageIcon(CommonSwing
113:                            .getIcon("BoldFont")));
114:
115:                    ckbbold.putClientProperty("is3DEnabled", Boolean.TRUE);
116:                    ckbbold.addActionListener(new ActionListener() {
117:
118:                        public void actionPerformed(ActionEvent e) {
119:                            setStyle();
120:                        }
121:                    });
122:
123:                    fgColorButton = new JButton("Foreground", new ImageIcon(
124:                            CommonSwing.getIcon("ColorSelection")));
125:
126:                    fgColorButton
127:                            .putClientProperty("is3DEnabled", Boolean.TRUE);
128:                    fgColorButton.addActionListener(new ActionListener() {
129:
130:                        public void actionPerformed(ActionEvent e) {
131:                            setColor(FOREGROUND);
132:                        }
133:                    });
134:
135:                    bgColorButton = new JButton("Background", new ImageIcon(
136:                            CommonSwing.getIcon("ColorSelection")));
137:
138:                    bgColorButton
139:                            .putClientProperty("is3DEnabled", Boolean.TRUE);
140:                    bgColorButton.addActionListener(new ActionListener() {
141:
142:                        public void actionPerformed(ActionEvent e) {
143:                            setColor(BACKGROUND);
144:                        }
145:                    });
146:
147:                    closeButton = new JButton("Close", new ImageIcon(
148:                            CommonSwing.getIcon("Close")));
149:
150:                    closeButton.putClientProperty("is3DEnabled", Boolean.TRUE);
151:                    closeButton.addActionListener(new ActionListener() {
152:
153:                        public void actionPerformed(ActionEvent e) {
154:                            frame.setVisible(false);
155:                        }
156:                    });
157:
158:                    GraphicsEnvironment ge = GraphicsEnvironment
159:                            .getLocalGraphicsEnvironment();
160:                    String[] fontNames = ge.getAvailableFontFamilyNames();
161:                    Dimension fontsComboBoxDimension = new Dimension(160, 25);
162:
163:                    fontsComboBox = new JComboBox(fontNames);
164:
165:                    fontsComboBox
166:                            .putClientProperty("is3DEnabled", Boolean.TRUE);
167:                    fontsComboBox.setMaximumSize(fontsComboBoxDimension);
168:                    fontsComboBox.setPreferredSize(fontsComboBoxDimension);
169:                    fontsComboBox.setMaximumSize(fontsComboBoxDimension);
170:                    fontsComboBox.setEditable(false);
171:                    fontsComboBox.setSelectedItem(defaultFont);
172:                    fontsComboBox.addActionListener(new ActionListener() {
173:
174:                        public void actionPerformed(ActionEvent e) {
175:                            setFont();
176:                        }
177:                    });
178:
179:                    // weconsultants@users 20050215 - Added for Compatbilty fix for  JDK 1.3
180:                    fontSizesComboBox = new JComboBox(fontSizes);
181:
182:                    Dimension spinnerDimension = new Dimension(45, 25);
183:
184:                    fontSizesComboBox.putClientProperty("is3DEnabled",
185:                            Boolean.TRUE);
186:                    fontSizesComboBox.setMinimumSize(spinnerDimension);
187:                    fontSizesComboBox.setPreferredSize(spinnerDimension);
188:                    fontSizesComboBox.setMaximumSize(spinnerDimension);
189:                    fontSizesComboBox.addItemListener(new ItemListener() {
190:
191:                        public void itemStateChanged(ItemEvent evt) {
192:
193:                            if (evt.getStateChange() == ItemEvent.SELECTED) {
194:                                setFontSize((String) evt.getItem());
195:                            }
196:                        }
197:                    });
198:
199:                    // weconsultants@users 20050215 - Commented out for Compatbilty fix for  JDK 1.3
200:                    //            Dimension spinnerDimension = new Dimension(50, 25);
201:                    //            spinnerFontSizes = new JSpinner();
202:                    //            spinnerFontSizes.putClientProperty("is3DEnabled", Boolean.TRUE);
203:                    //            spinnerFontSizes.setMinimumSize(spinnerDimension);
204:                    //            spinnerFontSizes.setPreferredSize(spinnerDimension);
205:                    //            spinnerFontSizes.setMaximumSize(spinnerDimension);
206:                    //            spinnerModelSizes = new SpinnerNumberModel(12, 8, 72, 1);
207:                    //            spinnerFontSizes.setModel(spinnerModelSizes);
208:                    //            spinnerFontSizes.addChangeListener(new ChangeListener() {
209:                    //                public void stateChanged(ChangeEvent e) {
210:                    //                    setFontSize();
211:                    //                }
212:                    //            });
213:                    Container contentPane = frame.getContentPane();
214:
215:                    contentPane.setLayout(new FlowLayout());
216:                    contentPane.add(fontsComboBox);
217:
218:                    // weconsultants@users 20050215 - Commented out for Compatbilty fix for 1.3
219:                    // contentPane.add(spinnerFontSizes);
220:                    // weconsultants@users 20050215 - Added for Compatbilty fix for 1.3
221:                    contentPane.add(fontSizesComboBox);
222:                    contentPane.add(ckbbold);
223:                    contentPane.add(ckbitalic);
224:                    contentPane.add(fgColorButton);
225:                    contentPane.add(bgColorButton);
226:                    contentPane.add(closeButton);
227:                    frame.pack();
228:                    frame.setVisible(false);
229:                }
230:            }
231:
232:            public static void setFont() {
233:
234:                Font txtResultFont = fOwner.txtResult.getFont();
235:
236:                fOwner.txtResult.setFont(new Font(fontsComboBox
237:                        .getSelectedItem().toString(),
238:                        txtResultFont.getStyle(), txtResultFont.getSize()));
239:
240:                Font txtCommandFont = fOwner.txtResult.getFont();
241:
242:                fOwner.txtCommand.setFont(new Font(fontsComboBox
243:                        .getSelectedItem().toString(), txtCommandFont
244:                        .getStyle(), txtCommandFont.getSize()));
245:
246:                Font txtTreeFont = fOwner.txtResult.getFont();
247:
248:                fOwner.tTree.setFont(new Font(fontsComboBox.getSelectedItem()
249:                        .toString(), txtTreeFont.getStyle(), txtTreeFont
250:                        .getSize()));
251:            }
252:
253:            /**
254:             * Displays a color chooser and Sets the selected color.
255:             */
256:            public static void setFontSize(String inFontSize) {
257:
258:                // weconsultants@users 20050215 - Changed for Compatbilty fix for JDK 1.3
259:                // Convert Strng to float for deriveFont() call
260:                Float stageFloat = new Float(inFontSize);
261:                float fontSize = stageFloat.floatValue();
262:                Font fonttTree = fOwner.tTree.getFont().deriveFont(fontSize);
263:
264:                fOwner.tTree.setFont(fonttTree);
265:
266:                Font fontTxtCommand = fOwner.txtCommand.getFont().deriveFont(
267:                        fontSize);
268:
269:                fOwner.txtCommand.setFont(fontTxtCommand);
270:
271:                Font fontTxtResult = fOwner.txtResult.getFont().deriveFont(
272:                        fontSize);
273:
274:                fOwner.txtResult.setFont(fontTxtResult);
275:            }
276:
277:            /**
278:             * Changes the style (Bold, Italic ) of the selected text by checking the
279:             * style buttons
280:             */
281:            public static void setStyle() {
282:
283:                int style = Font.PLAIN;
284:
285:                if (ckbbold.isSelected()) {
286:                    style |= Font.BOLD;
287:                }
288:
289:                if (ckbitalic.isSelected()) {
290:                    style |= Font.ITALIC;
291:                }
292:
293:                fOwner.tTree.setFont(fOwner.txtCommand.getFont().deriveFont(
294:                        style));
295:                fOwner.txtCommand.setFont(fOwner.txtCommand.getFont()
296:                        .deriveFont(style));
297:                fOwner.txtResult.setFont(fOwner.txtResult.getFont().deriveFont(
298:                        style));
299:            }
300:
301:            public static void setColor(String inTarget) {
302:
303:                if (inTarget.equals(BACKGROUND)) {
304:                    Color backgroundColor = JColorChooser.showDialog(null,
305:                            "DataBaseManagerSwing Choose Background Color",
306:                            fOwner.txtResult.getBackground());
307:
308:                    if (backgroundColor != null) {
309:                        bgColorButton.setBackground(backgroundColor);
310:                        fOwner.txtCommand.setBackground(backgroundColor);
311:                        fOwner.txtResult.setBackground(backgroundColor);
312:                    }
313:                } else {
314:                    Color foregroundColor = JColorChooser.showDialog(null,
315:                            "DataBaseManagerSwing Choose Foreground Color",
316:                            fOwner.txtResult.getForeground());
317:
318:                    if (foregroundColor != null) {
319:                        fgColorButton.setBackground(foregroundColor);
320:                        fOwner.txtCommand.setForeground(foregroundColor);
321:                        fOwner.txtResult.setForeground(foregroundColor);
322:                    }
323:                }
324:            }
325:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.