Source Code Cross Referenced for PasswordInputWindow.java in  » Database-Client » DBBrowser » org » dbbrowser » ui » panel » connectioninformationwindow » 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 » DBBrowser » org.dbbrowser.ui.panel.connectioninformationwindow 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.dbbrowser.ui.panel.connectioninformationwindow;
002:
003:        import java.awt.event.ActionEvent;
004:        import java.awt.event.ActionListener;
005:        import java.awt.event.KeyAdapter;
006:        import java.awt.event.KeyEvent;
007:        import infrastructure.internationalization.InternationalizationManager;
008:        import infrastructure.propertymanager.PropertyManager;
009:        import javax.swing.ImageIcon;
010:        import javax.swing.JButton;
011:        import javax.swing.JDialog;
012:        import javax.swing.JFrame;
013:        import javax.swing.JLabel;
014:        import javax.swing.JOptionPane;
015:        import javax.swing.JPasswordField;
016:        import org.dbbrowser.ui.UIControllerForQueries;
017:
018:        /**
019:         * This class presents the user with a UI which is used to enter a password
020:         * @author amangat
021:         *
022:         */
023:        public class PasswordInputWindow extends JDialog implements 
024:                ActionListener {
025:            private static final String TITLE = InternationalizationManager
026:                    .getInstance().getMessage("dbbrowser-ui",
027:                            "dbbrowser-ui-dbbrowser-window-title-label", null);;
028:
029:            private static final long serialVersionUID = UIControllerForQueries.version;
030:            private static final String PASSWORD_1_INPUT_LABEL = InternationalizationManager
031:                    .getInstance()
032:                    .getMessage(
033:                            "dbbrowser-ui",
034:                            "dbbrowser-ui-known-connections-panel-type-password-label",
035:                            null);
036:            private static final String PASSWORD_2_INPUT_LABEL = InternationalizationManager
037:                    .getInstance()
038:                    .getMessage(
039:                            "dbbrowser-ui",
040:                            "dbbrowser-ui-known-connections-panel-re-type-password-label",
041:                            null);
042:            private static final String PASSWORDS_DONT_MATCH_ERROR_MESSAGE = InternationalizationManager
043:                    .getInstance()
044:                    .getMessage(
045:                            "dbbrowser-ui",
046:                            "dbbrowser-ui-known-connections-panel-passwords-dont-match",
047:                            null);
048:            private static final String OK_BUTTON_LABEL = InternationalizationManager
049:                    .getInstance()
050:                    .getMessage(
051:                            "dbbrowser-ui",
052:                            "dbbrowser-ui-first-run-message-dialog-ok-button-label",
053:                            null);
054:            private static final String OK_BUTTON_ICON_FILENAME = PropertyManager
055:                    .getInstance()
056:                    .getProperty(
057:                            "dbbrowser-ui-view-record-window-update-record-icon");
058:
059:            private JLabel label1 = new JLabel(PASSWORD_1_INPUT_LABEL);
060:            private JPasswordField passwordField1 = new JPasswordField();
061:            private JLabel label2 = new JLabel(PASSWORD_2_INPUT_LABEL);
062:            private JPasswordField passwordField2 = new JPasswordField();
063:            private JButton okButton = new JButton(OK_BUTTON_LABEL);
064:            private String password = null;
065:            private boolean confirmPassword = true;
066:
067:            public PasswordInputWindow(Boolean confirmPassword) {
068:                this .setTitle(TITLE);
069:                this .setSize(300, 200);
070:                this .setLocationRelativeTo(null);
071:                this .setResizable(false);
072:                this .setModal(true);
073:
074:                this .confirmPassword = confirmPassword.booleanValue();
075:
076:                this .getContentPane().setLayout(null);
077:
078:                this .label1.setBounds(30, 30, 130, 30);
079:                this .passwordField1.setBounds(160, 30, 120, 30);
080:                this .label2.setBounds(30, 90, 130, 30);
081:                this .passwordField2.setBounds(160, 90, 120, 30);
082:                this .okButton.setBounds(100, 130, 100, 30);
083:
084:                this .passwordField1
085:                        .addKeyListener(new PasswordFieldKeyAdapter());
086:                this .passwordField2
087:                        .addKeyListener(new PasswordFieldKeyAdapter());
088:                this .okButton.addActionListener(this );
089:                this .okButton.setIcon(new ImageIcon(OK_BUTTON_ICON_FILENAME));
090:                this .okButton.setEnabled(false);
091:
092:                this .getContentPane().add(label1);
093:                this .getContentPane().add(passwordField1);
094:
095:                //If confirmation is required, add second field
096:                if (this .confirmPassword) {
097:                    this .getContentPane().add(label2);
098:                    this .getContentPane().add(passwordField2);
099:                }
100:                this .getContentPane().add(okButton);
101:
102:                this .setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
103:            }
104:
105:            public String getPassword() {
106:                return this .password;
107:            }
108:
109:            public void actionPerformed(ActionEvent e) {
110:                String password1 = new String(this .passwordField1.getPassword());
111:                String password2 = new String(this .passwordField2.getPassword());
112:
113:                //if confirmation of 2 passwords required, do the check
114:                if (this .confirmPassword) {
115:                    if (password1 != null && password2 != null
116:                            && (!"".equals(password1))
117:                            && (!"".equals(password2))
118:                            && password1.equals(password2)) {
119:                        this .password = password1;
120:                        this .hide();
121:                        this .pack();
122:                    } else {
123:                        this .okButton.setEnabled(false);
124:                        this .passwordField1.setText("");
125:                        this .passwordField2.setText("");
126:                        this .passwordField1.requestFocus();
127:                        JOptionPane.showMessageDialog(null,
128:                                PASSWORDS_DONT_MATCH_ERROR_MESSAGE, TITLE,
129:                                JOptionPane.ERROR_MESSAGE);
130:                    }
131:                } else {
132:                    this .password = password1;
133:                    this .hide();
134:                    this .pack();
135:                }
136:            }
137:
138:            private class PasswordFieldKeyAdapter extends KeyAdapter {
139:                public void keyTyped(KeyEvent e) {
140:                    if (confirmPassword) {
141:                        if (passwordField1.getPassword().length > 0
142:                                && passwordField2.getPassword().length > 0) {
143:                            okButton.setEnabled(true);
144:                        } else {
145:                            okButton.setEnabled(false);
146:                        }
147:                    } else {
148:                        if (passwordField1.getPassword().length > 0) {
149:                            okButton.setEnabled(true);
150:                        } else {
151:                            okButton.setEnabled(false);
152:                        }
153:                    }
154:                }
155:            }
156:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.