Source Code Cross Referenced for WbFontPicker.java in  » Database-Client » SQL-Workbench » workbench » gui » components » 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 Client » SQL Workbench » workbench.gui.components 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * WbFontPicker.java
003:         *
004:         * This file is part of SQL Workbench/J, http://www.sql-workbench.net
005:         *
006:         * Copyright 2002-2008, Thomas Kellerer
007:         * No part of this code maybe reused without the permission of the author
008:         *
009:         * To contact the author please send an email to: support@sql-workbench.net
010:         *
011:         */
012:        package workbench.gui.components;
013:
014:        import java.awt.Dimension;
015:        import java.awt.Font;
016:        import java.io.Serializable;
017:        import javax.swing.JDialog;
018:        import javax.swing.JOptionPane;
019:        import javax.swing.JPanel;
020:        import javax.swing.SwingUtilities;
021:        import javax.swing.UIManager;
022:        import workbench.gui.WbSwingUtilities;
023:        import workbench.resource.ResourceMgr;
024:
025:        /**
026:         *
027:         * @author support@sql-workbench.net
028:         */
029:        public class WbFontPicker extends JPanel implements  Serializable {
030:            private Font selectedFont;
031:            private boolean monospacedOnly = false;
032:            private boolean allowFontReset = false;
033:
034:            /** Creates new form WbFontPicker */
035:            public WbFontPicker() {
036:                initComponents();
037:                this .setAllowFontReset(false);
038:            }
039:
040:            public void setAllowFontReset(boolean flag) {
041:                this .allowFontReset = flag;
042:                this .resetButton.setVisible(flag);
043:                this .resetButton.setEnabled(flag);
044:                if (flag) {
045:                    this .resetButton.setIcon(ResourceMgr.getImage("Delete"));
046:                }
047:            }
048:
049:            public void setListMonospacedOnly(boolean flag) {
050:                this .monospacedOnly = flag;
051:            }
052:
053:            /** This method is called from within the constructor to
054:             * initialize the form.
055:             * WARNING: Do NOT modify this code. The content of this method is
056:             * always regenerated by the Form Editor.
057:             */
058:            // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
059:            private void initComponents() {
060:                java.awt.GridBagConstraints gridBagConstraints;
061:
062:                fontName = new javax.swing.JLabel();
063:                selectFontButton = new FlatButton();
064:                resetButton = new FlatButton();
065:
066:                setLayout(new java.awt.GridBagLayout());
067:
068:                fontName.setText("jLabel1");
069:                fontName.setBorder(javax.swing.BorderFactory
070:                        .createCompoundBorder(javax.swing.BorderFactory
071:                                .createEtchedBorder(),
072:                                javax.swing.BorderFactory.createEmptyBorder(1,
073:                                        5, 1, 5)));
074:                fontName.setMaximumSize(new java.awt.Dimension(45, 22));
075:                fontName.setMinimumSize(new java.awt.Dimension(45, 22));
076:                fontName.setPreferredSize(new java.awt.Dimension(45, 22));
077:                gridBagConstraints = new java.awt.GridBagConstraints();
078:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
079:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
080:                gridBagConstraints.weightx = 1.0;
081:                gridBagConstraints.weighty = 1.0;
082:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 5);
083:                add(fontName, gridBagConstraints);
084:
085:                selectFontButton.setText("...");
086:                selectFontButton.setMaximumSize(new java.awt.Dimension(22, 22));
087:                selectFontButton.setMinimumSize(new java.awt.Dimension(22, 22));
088:                selectFontButton
089:                        .setPreferredSize(new java.awt.Dimension(22, 22));
090:                selectFontButton
091:                        .addMouseListener(new java.awt.event.MouseAdapter() {
092:                            public void mouseClicked(
093:                                    java.awt.event.MouseEvent evt) {
094:                                selectFontButtonMouseClicked(evt);
095:                            }
096:                        });
097:                gridBagConstraints = new java.awt.GridBagConstraints();
098:                gridBagConstraints.gridx = 2;
099:                gridBagConstraints.gridy = 0;
100:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
101:                add(selectFontButton, gridBagConstraints);
102:
103:                resetButton.setToolTipText(ResourceMgr
104:                        .getDescription("LblResetFont"));
105:                resetButton.setMaximumSize(new java.awt.Dimension(22, 22));
106:                resetButton.setMinimumSize(new java.awt.Dimension(22, 22));
107:                resetButton.setPreferredSize(new java.awt.Dimension(22, 22));
108:                resetButton
109:                        .addActionListener(new java.awt.event.ActionListener() {
110:                            public void actionPerformed(
111:                                    java.awt.event.ActionEvent evt) {
112:                                resetButtonActionPerformed(evt);
113:                            }
114:                        });
115:                gridBagConstraints = new java.awt.GridBagConstraints();
116:                gridBagConstraints.gridx = 1;
117:                gridBagConstraints.gridy = 0;
118:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 3);
119:                add(resetButton, gridBagConstraints);
120:            }// </editor-fold>//GEN-END:initComponents
121:
122:            private void resetButtonActionPerformed(
123:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resetButtonActionPerformed
124:                this .setSelectedFont(null);
125:            }//GEN-LAST:event_resetButtonActionPerformed
126:
127:            private void selectFontButtonMouseClicked(
128:                    java.awt.event.MouseEvent evt)//GEN-FIRST:event_selectFontButtonMouseClicked
129:            {//GEN-HEADEREND:event_selectFontButtonMouseClicked
130:                WbFontChooser chooser = new WbFontChooser(monospacedOnly,
131:                        allowFontReset);
132:                chooser.setSelectedFont(getSelectedFont());
133:                Dimension d = new Dimension(320, 240);
134:                chooser.setSize(d);
135:                chooser.setPreferredSize(d);
136:
137:                JOptionPane option = new JOptionPane(chooser,
138:                        JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
139:                JDialog dialog = option.createDialog(this , ResourceMgr
140:                        .getString("TxtWindowTitleChooseFont"));
141:                dialog.pack();
142:                WbSwingUtilities.center(dialog, SwingUtilities
143:                        .getWindowAncestor(this ));
144:                dialog.setVisible(true);
145:                dialog.dispose();
146:
147:                if (chooser.isFontReset()) {
148:                    this .setSelectedFont(null);
149:                    return;
150:                }
151:
152:                Object value = option.getValue();
153:                if (value == null)
154:                    return;
155:                Font result = null;
156:                if (value instanceof  Integer) {
157:                    int answer = ((Integer) value).intValue();
158:                    if (answer == JOptionPane.OK_OPTION) {
159:                        result = chooser.getSelectedFont();
160:                    }
161:                }
162:                if (result != null) {
163:                    this .setSelectedFont(result);
164:                }
165:
166:            }//GEN-LAST:event_selectFontButtonMouseClicked
167:
168:            public Font getSelectedFont() {
169:                return this .selectedFont;
170:            }
171:
172:            public void setSelectedFont(Font f) {
173:                this .selectedFont = f;
174:                if (f == null) {
175:                    Font df = UIManager.getDefaults().getFont("Label.font");
176:                    this .fontName.setFont(df);
177:                    this .fontName.setText(ResourceMgr
178:                            .getString("LblDefaultIndicator"));
179:                } else {
180:                    this .fontName.setFont(f);
181:                    this .fontName.setText(f.getFontName() + ", " + f.getSize());
182:                }
183:            }
184:
185:            // Variables declaration - do not modify//GEN-BEGIN:variables
186:            private javax.swing.JLabel fontName;
187:            private javax.swing.JButton resetButton;
188:            private javax.swing.JButton selectFontButton;
189:            // End of variables declaration//GEN-END:variables
190:
191:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.