Source Code Cross Referenced for LoginDialog.java in  » Database-Client » iSQL-Viewer » org » isqlviewer » swing » 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 » iSQL Viewer » org.isqlviewer.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the Mozilla Public License
003:         * Version 1.1 (the "License"); you may not use this file except in
004:         * compliance with the License. You may obtain a copy of the License at
005:         * http://www.mozilla.org/MPL/
006:         *
007:         * Software distributed under the License is distributed on an "AS IS"
008:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
009:         * License for the specific language governing rights and limitations
010:         * under the License.
011:         * 
012:         * The Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
013:         *
014:         * The Initial Developer of the Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
015:         * Portions created by Mark A. Kobold are Copyright (C) 2000-2007. All Rights Reserved.
016:         *
017:         * Contributor(s): 
018:         *  Mark A. Kobold [mkobold <at> isqlviewer <dot> com].
019:         *  
020:         * If you didn't download this code from the following link, you should check
021:         * if you aren't using an obsolete version: http://www.isqlviewer.com
022:         */
023:        package org.isqlviewer.swing;
024:
025:        import java.awt.BorderLayout;
026:        import java.awt.Component;
027:        import java.awt.Container;
028:        import java.awt.Frame;
029:        import java.awt.GridBagConstraints;
030:        import java.awt.GridBagLayout;
031:        import java.awt.Insets;
032:        import java.awt.event.ActionEvent;
033:        import java.awt.event.ActionListener;
034:        import java.awt.event.WindowEvent;
035:
036:        import javax.swing.Box;
037:        import javax.swing.JButton;
038:        import javax.swing.JComponent;
039:        import javax.swing.JDialog;
040:        import javax.swing.JFrame;
041:        import javax.swing.JLabel;
042:        import javax.swing.JPanel;
043:        import javax.swing.JPasswordField;
044:        import javax.swing.JTextField;
045:
046:        import org.isqlviewer.util.LocalMessages;
047:
048:        /**
049:         * @author Markus A. Kobold &lt;mkobold at sprintpcs dot com&gt;
050:         */
051:        public class LoginDialog extends JDialog implements  ActionListener {
052:
053:            private static final long serialVersionUID = -1870688453773372222L;
054:
055:            private static final GridBagConstraints UI_CONSTRAINT = new GridBagConstraints(
056:                    0, 0, 0, 0, 0, 0, 0, 0, new Insets(1, 1, 1, 1), 0, 0);
057:
058:            private static final String BUNDLE_IDENTIFIER = "org.isqlviewer.swing.ResourceBundle";
059:            private static final LocalMessages messages = new LocalMessages(
060:                    BUNDLE_IDENTIFIER);
061:
062:            private JTextField principal = new JTextField("", 16);
063:            private JPasswordField credentials = new JPasswordField("", 16);
064:            private JButton okButton = new JButton(messages
065:                    .getMessage("logindialog.okbutton"));
066:            private JButton cancelButton = new JButton(messages
067:                    .getMessage("logindialog.cancelbutton"));
068:            private String[] tokens = null;
069:
070:            public LoginDialog(Frame frameParent) {
071:
072:                super (frameParent, messages.getMessage("logindialog.title"),
073:                        true);
074:                initializeUI();
075:            }
076:
077:            public String[] getAuthTokens() {
078:
079:                return tokens;
080:            }
081:
082:            public void actionPerformed(ActionEvent e) {
083:
084:                Object src = e.getSource();
085:                if (src.equals(credentials) || src.equals(okButton)) {
086:                    tokens = new String[2];
087:                    tokens[0] = principal.getText();
088:                    tokens[1] = new String(credentials.getPassword());
089:                    dispose();
090:                } else if (src.equals(cancelButton)) {
091:                    tokens = null;
092:                    dispose();
093:                } else if (src.equals(principal)) {
094:                    credentials.requestFocus();
095:                }
096:            }
097:
098:            @Override
099:            protected void processWindowEvent(WindowEvent e) {
100:
101:                switch (e.getID()) {
102:                case WindowEvent.WINDOW_OPENED:
103:                    principal.requestFocus();
104:                    principal.setText(System.getProperty("user.name"));
105:                    setLocationRelativeTo(getOwner());
106:                    break;
107:                }
108:                super .processWindowEvent(e);
109:            }
110:
111:            private void initializeUI() {
112:
113:                Component component = null;
114:                Object constraint = null;
115:
116:                JPanel contentPanel = new JPanel(new GridBagLayout());
117:
118:                component = new JLabel(messages
119:                        .getMessage("logindialog.username.title"));
120:                ((JLabel) component).setLabelFor(principal);
121:                constraint = constrain(0, 0, 1, 1, 0.0d, 0.0d,
122:                        GridBagConstraints.WEST, GridBagConstraints.NONE);
123:                contentPanel.add(component, constraint);
124:
125:                component = new JLabel(messages
126:                        .getMessage("logindialog.password.title"));
127:                ((JLabel) component).setLabelFor(credentials);
128:                constraint = constrain(0, 1, 1, 1, 0.0d, 0.0d,
129:                        GridBagConstraints.WEST, GridBagConstraints.NONE);
130:                contentPanel.add(component, constraint);
131:
132:                component = principal;
133:                constraint = constrain(1, 0, 1, 1, 1.0d, 1.0d,
134:                        GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL);
135:                contentPanel.add(component, constraint);
136:
137:                component = credentials;
138:                constraint = constrain(1, 1, 1, 1, 1.0d, 1.0d,
139:                        GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL);
140:                contentPanel.add(component, constraint);
141:
142:                component = Box.createVerticalStrut(10);
143:                constraint = constrain(0, 2, 2, 1, 0.0d, 0.0d,
144:                        GridBagConstraints.WEST, GridBagConstraints.NONE);
145:                contentPanel.add(component, constraint);
146:
147:                JComponent commandPanel = new JPanel(new GridBagLayout());
148:                JButton actionButton = null;
149:
150:                constraint = constrain(0, 0, 1, 1, 1.0d, 0.0d,
151:                        GridBagConstraints.CENTER,
152:                        GridBagConstraints.HORIZONTAL);
153:                commandPanel.add(Box.createHorizontalStrut(10), constraint);
154:
155:                constraint = constrain(1, 0, 1, 1, 1.0d, 0.0d,
156:                        GridBagConstraints.CENTER,
157:                        GridBagConstraints.HORIZONTAL);
158:                commandPanel.add(Box.createHorizontalGlue(), constraint);
159:
160:                actionButton = okButton;
161:                actionButton.addActionListener(this );
162:                actionButton.setActionCommand(Integer.toString(0));
163:                actionButton.setToolTipText(messages
164:                        .getMessage("logindialog.okbutton.tip"));
165:                constraint = constrain(2, 0, 1, 1, 0.0d, 0.0d,
166:                        GridBagConstraints.CENTER, GridBagConstraints.NONE);
167:                commandPanel.add(actionButton, constraint);
168:
169:                actionButton = cancelButton;
170:                actionButton.addActionListener(this );
171:                actionButton.setActionCommand(Integer.toString(1));
172:                actionButton.setToolTipText(messages
173:                        .getMessage("logindialog.cancelbutton.tip"));
174:                constraint = constrain(3, 0, 1, 1, 0.0d, 0.0d,
175:                        GridBagConstraints.CENTER, GridBagConstraints.NONE);
176:                commandPanel.add(actionButton, constraint);
177:
178:                constraint = constrain(4, 0, 1, 1, 0.0d, 0.0d,
179:                        GridBagConstraints.CENTER,
180:                        GridBagConstraints.HORIZONTAL);
181:                commandPanel.add(Box.createHorizontalStrut(10), constraint);
182:
183:                constraint = constrain(0, 1, 5, 1, 0.0d, 0.0d,
184:                        GridBagConstraints.CENTER,
185:                        GridBagConstraints.HORIZONTAL);
186:                commandPanel.add(Box.createVerticalStrut(10), constraint);
187:
188:                getRootPane().setDefaultButton(okButton);
189:                setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
190:
191:                Container container = new JPanel(new BorderLayout());
192:                container.add(contentPanel, BorderLayout.CENTER);
193:                container.add(commandPanel, BorderLayout.SOUTH);
194:                container.add(Box.createVerticalStrut(10), BorderLayout.NORTH);
195:                container.add(Box.createHorizontalStrut(10), BorderLayout.WEST);
196:                container.add(Box.createHorizontalStrut(10), BorderLayout.EAST);
197:
198:                setContentPane(container);
199:                setResizable(false);
200:                pack();
201:            }
202:
203:            private static GridBagConstraints constrain(int x, int y, int w,
204:                    int h, double wx, double wy, int a, int f) {
205:
206:                UI_CONSTRAINT.gridx = x;
207:                UI_CONSTRAINT.gridy = y;
208:                UI_CONSTRAINT.gridwidth = w;
209:                UI_CONSTRAINT.gridheight = h;
210:                UI_CONSTRAINT.weightx = wx;
211:                UI_CONSTRAINT.weighty = wy;
212:                UI_CONSTRAINT.anchor = a;
213:                UI_CONSTRAINT.fill = f;
214:                return UI_CONSTRAINT;
215:            }
216:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.