Changeset 289 in tmcsimulator
- Timestamp:
- 03/02/2019 12:56:15 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/client/cadclientgui/screens/Login.java
r59 r289 7 7 import java.awt.event.ActionEvent; 8 8 import java.awt.event.ActionListener; 9 import java.awt.event.KeyEvent; 10 import java.awt.event.KeyListener; 9 11 import javax.swing.Box; 10 12 import javax.swing.BoxLayout; … … 24 26 * @author Vincent 25 27 */ 26 public class Login extends JFrame 28 public class Login extends JFrame implements KeyListener 27 29 { 28 30 private Box login; … … 125 127 126 128 Box leftBox = new Box(BoxLayout.Y_AXIS); 127 leftBox.setMaximumSize(new Dimension(350, 50));128 leftBox.setMinimumSize(new Dimension(350, 50));129 leftBox.setPreferredSize(new Dimension(350, 50));129 leftBox.setMaximumSize(new Dimension(350, 90)); 130 leftBox.setMinimumSize(new Dimension(350, 90)); 131 leftBox.setPreferredSize(new Dimension(350, 90)); 130 132 leftBox.setAlignmentX(LEFT_ALIGNMENT); 131 133 … … 133 135 userNameLabel.setForeground(Color.WHITE); 134 136 userNameField = new JTextField(kNamePrompt); 137 userNameField.addKeyListener(this); 138 userNameField.setForeground(Color.GRAY); 135 139 Box userNameBox = new Box(BoxLayout.X_AXIS); 136 140 userNameBox.setAlignmentX(LEFT_ALIGNMENT); … … 143 147 passwordLabel.setForeground(Color.WHITE); 144 148 passwordField = new JTextField("Not required"); 149 passwordField.setEnabled(false); 145 150 Box passwordBox = new Box(BoxLayout.X_AXIS); 146 151 passwordBox.setAlignmentX(LEFT_ALIGNMENT); … … 207 212 setVisible(true); 208 213 } 214 215 /** 216 * This keylistener removes the prompt displayed in the username text box 217 * the first time the user presses a key. Fixes #96 218 * @author jdalbey 219 * @param evt 220 */ 221 public void keyPressed(KeyEvent evt) 222 { 223 // See if the text in the box is the initial prompt 224 // If so, the user hasn't typed anything yet, this is the 1st keypress 225 // Even the shift key will be caught here. 226 if (userNameField.getText().equals(kNamePrompt)) 227 { 228 userNameField.setText(""); 229 // Change the text color from gray to black 230 userNameField.setForeground(Color.BLACK); 231 } 232 } 233 234 public void keyReleased(KeyEvent e) {} 235 public void keyTyped(KeyEvent e) {} 209 236 }
Note: See TracChangeset
for help on using the changeset viewer.
