source: release-kits/shared/ant-installer/src/org/tp23/antinstaller/renderer/swing/PasswordTextInputRenderer.java@ 15210

Last change on this file since 15210 was 15210, checked in by oranfry, 16 years ago

Lots of changes to the installer. Now only look in LanguagePack resource bundle for strings.

File size: 2.2 KB
Line 
1/*
2 * Copyright 2005 Paul Hinds
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.tp23.antinstaller.renderer.swing;
17
18import java.awt.Color;
19import java.awt.event.KeyAdapter;
20import java.awt.event.KeyEvent;
21import java.util.ResourceBundle;
22
23import javax.swing.JPanel;
24
25import org.tp23.antinstaller.renderer.MessageRenderer;
26import org.tp23.gui.GBCF;
27
28public class PasswordTextInputRenderer extends ValidatedTextInputRenderer{
29
30 private static final ResourceBundle res = ResourceBundle.getBundle("resources.LanguagePack");
31
32 public PasswordTextInputRenderer() {
33 this.jTextField = new AIPasswordField();
34 origFore = jTextField.getForeground(); // this is lazy there must be a way to shift this line of code to the superclass (is it worth it)
35 }
36
37
38 public void renderError() {
39 MessageRenderer mr = ctx.getMessageRenderer();
40 mr.printMessage( getErrorMessage() );
41 // fixed BUG:1295944 mr.printMessage("The password is not of the correct format\n\n e.g. "+inputField.getDefaultValue());
42 this.jTextField.requestFocus();
43 this.jTextField.setForeground(Color.red);
44 jTextField.addKeyListener(new KeyAdapter() {
45 public void keyTyped(KeyEvent e) {
46 if(e.getKeyChar() != '\t'){
47 inputField.setEditted(true);
48 }
49 }
50 });
51 }
52 public int addSelf(JPanel content, GBCF cf, int row, boolean overflow) {
53 content.add(fieldLabel, cf.getCell(row, 0));
54 content.add(jTextField, cf.getCell(row, 1));
55 if(overflow){
56 ((AIPasswordField)jTextField).setOverflow(SizeConstants.OVERFLOW_FIELD_SIZE);
57 }
58 return ++row;
59 }
60 protected String getErrorMessage(){
61 return res.getString("notCorrectPasswordFormat") +
62 "\n\n e.g. " +
63 inputField.getDefaultValue();
64 }
65
66}
Note: See TracBrowser for help on using the repository browser.