Source Code Cross Referenced for LoginDialog.java in  » Development » rapla » org » rapla » client » internal » 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 » Development » rapla » org.rapla.client.internal 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*--------------------------------------------------------------------------*
002:         | Copyright (C) 2006 Christopher Kohlhaas, Frithjof Kurtz                  |
003:         |                                                                          |
004:         | This program is free software; you can redistribute it and/or modify     |
005:         | it under the terms of the GNU General Public License as published by the |
006:         | Free Software Foundation. A copy of the license has been included with   |
007:         | these distribution in the COPYING file, if not go to www.fsf.org         |
008:         |                                                                          |
009:         | As a special exception, you are granted the permissions to link this     |
010:         | program with every library, which license fulfills the Open Source       |
011:         | Definition as published by the Open Source Initiative (OSI).             |
012:         *--------------------------------------------------------------------------*/
013:        package org.rapla.client.internal;
014:
015:        import java.awt.BorderLayout;
016:        import java.awt.Container;
017:        import java.awt.GridLayout;
018:        import java.awt.event.ActionEvent;
019:        import java.awt.event.ActionListener;
020:        import java.awt.event.FocusAdapter;
021:        import java.awt.event.FocusEvent;
022:
023:        import javax.swing.Action;
024:        import javax.swing.BorderFactory;
025:        import javax.swing.Box;
026:        import javax.swing.BoxLayout;
027:        import javax.swing.JButton;
028:        import javax.swing.JComponent;
029:        import javax.swing.JLabel;
030:        import javax.swing.JPanel;
031:        import javax.swing.JPasswordField;
032:        import javax.swing.JTextField;
033:
034:        import org.rapla.components.layout.TableLayout;
035:        import org.rapla.components.xmlbundle.I18nBundle;
036:        import org.rapla.components.xmlbundle.LocaleChangeEvent;
037:        import org.rapla.components.xmlbundle.LocaleChangeListener;
038:        import org.rapla.components.xmlbundle.LocaleSelector;
039:        import org.rapla.framework.RaplaContext;
040:        import org.rapla.framework.RaplaException;
041:        import org.rapla.gui.toolkit.RaplaFrame;
042:
043:        public final class LoginDialog extends RaplaFrame implements 
044:                LocaleChangeListener {
045:            private static final long serialVersionUID = -1887723833652617352L;
046:
047:            JPanel jPanelFields = new JPanel();
048:
049:            JPanel langSelection = new JPanel();
050:            JLabel chooseLanguageLabel = new JLabel();
051:
052:            JTextField username = new JTextField(15);
053:            JPasswordField password = new JPasswordField(15);
054:
055:            JLabel usernameLabel = new JLabel();
056:            JLabel passwordLabel = new JLabel();
057:            JButton loginBtn = new JButton();
058:            JButton exitBtn = new JButton();
059:            JPanel content = new JPanel();
060:            I18nBundle i18n;
061:            protected LocaleSelector localeSelector;
062:
063:            public LoginDialog(RaplaContext sm) throws RaplaException {
064:                super (sm);
065:                i18n = (I18nBundle) sm.lookup(I18nBundle.ROLE
066:                        + "/org.rapla.RaplaResources");
067:                localeSelector = (LocaleSelector) sm
068:                        .lookup(LocaleSelector.ROLE);
069:                localeSelector.addLocaleChangeListener(this );
070:            }
071:
072:            public static LoginDialog create(RaplaContext sm,
073:                    JComponent infoPanel, JComponent languageSelector)
074:                    throws RaplaException {
075:                LoginDialog dlg = new LoginDialog(sm);
076:                dlg.init(infoPanel, languageSelector);
077:                return dlg;
078:            }
079:
080:            public void setLoginAction(Action action) {
081:                loginBtn.setAction(action);
082:            }
083:
084:            public void setExitAction(Action action) {
085:                exitBtn.setAction(action);
086:            }
087:
088:            private void init(JComponent infoPanel, JComponent languageSelector) {
089:                Container contentPane = getContentPane();
090:                content
091:                        .setBorder(BorderFactory
092:                                .createEmptyBorder(0, 10, 0, 10));
093:                content.setLayout(new BorderLayout());
094:                content.add(jPanelFields, BorderLayout.SOUTH);
095:                content.add(infoPanel, BorderLayout.CENTER);
096:
097:                langSelection.setLayout(new BoxLayout(langSelection,
098:                        BoxLayout.X_AXIS));
099:                langSelection.add(languageSelector);
100:                langSelection.add(Box.createHorizontalGlue());
101:
102:                double pre = TableLayout.PREFERRED;
103:                double fill = TableLayout.FILL;
104:                double[][] sizes = { { pre, 10, fill },
105:                        { pre, 5, pre, 5, pre, 5 } };
106:                TableLayout tableLayout = new TableLayout(sizes);
107:                jPanelFields.setLayout(tableLayout);
108:                jPanelFields.add(chooseLanguageLabel, "0,0");
109:                jPanelFields.add(usernameLabel, "0,2");
110:                jPanelFields.add(passwordLabel, "0,4");
111:                jPanelFields.add(langSelection, "2,0");
112:                jPanelFields.add(username, "2,2");
113:                jPanelFields.add(password, "2,4");
114:
115:                username.setColumns(14);
116:                password.setColumns(14);
117:                Listener listener = new Listener();
118:                password.addActionListener(listener);
119:                languageSelector.addFocusListener(listener);
120:
121:                contentPane.setLayout(new BorderLayout());
122:                contentPane.add(content, BorderLayout.CENTER);
123:                JPanel buttonPanel = new JPanel();
124:                GridLayout gridLayout = new GridLayout(1, 2);
125:                buttonPanel.setLayout(gridLayout);
126:                buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10,
127:                        10, 10));
128:                gridLayout.setHgap(20);
129:                contentPane.add(buttonPanel, BorderLayout.SOUTH);
130:                buttonPanel.add(exitBtn);
131:                buttonPanel.add(loginBtn);
132:                this .getRootPane().setDefaultButton(loginBtn);
133:                //  setDefault(1);
134:                setLocale();
135:                username.requestFocus();
136:            }
137:
138:            public String getUsername() {
139:                return username.getText();
140:            }
141:
142:            public char[] getPassword() {
143:                return password.getPassword();
144:            }
145:
146:            /** overrides localeChanged from DialogUI*/
147:            public void localeChanged(LocaleChangeEvent evt) {
148:                setLocale();
149:            }
150:
151:            private I18nBundle getI18n() {
152:                return i18n;
153:            }
154:
155:            private void setLocale() {
156:                chooseLanguageLabel.setText(getI18n().getString(
157:                        "choose_language"));
158:                exitBtn.setText(getI18n().getString("exit"));
159:                loginBtn.setText(getI18n().getString("login"));
160:                usernameLabel.setText(getI18n().getString("username") + ":");
161:                passwordLabel.setText(getI18n().getString("password") + ":");
162:                setTitle(getI18n().getString("logindialog.title"));
163:                repaint();
164:            }
165:
166:            public void dispose() {
167:                super .dispose();
168:                localeSelector.removeLocaleChangeListener(this );
169:            }
170:
171:            public void testEnter(String newUsername, String newPassword) {
172:                username.setText(newUsername);
173:                password.setText(newPassword);
174:            }
175:
176:            class Listener extends FocusAdapter implements  ActionListener {
177:                boolean bInit = false;
178:
179:                public void focusGained(FocusEvent e) {
180:                    if (!bInit) {
181:                        username.requestFocus();
182:                        bInit = true;
183:                    }
184:                }
185:
186:                public void actionPerformed(ActionEvent event) {
187:                    if (event.getSource() == password) {
188:                        loginBtn.doClick();
189:                        return;
190:                    } // end of if ()
191:                }
192:            }
193:
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.