Changeset 59 in tmcsimulator for trunk/src/tmcsim/client/cadclientgui/screens/Login.java
- Timestamp:
- 03/15/2017 10:20:21 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/client/cadclientgui/screens/Login.java
r3 r59 2 2 3 3 import java.awt.Color; 4 import static java.awt.Component.LEFT_ALIGNMENT; 4 5 import java.awt.Dimension; 5 6 import java.awt.Font; 6 7 import java.awt.event.ActionEvent; 7 8 import java.awt.event.ActionListener; 8 9 9 import javax.swing.Box; 10 10 import javax.swing.BoxLayout; … … 16 16 import javax.swing.SwingConstants; 17 17 18 19 18 /** 20 * This class contains the view and controller for the Login screen. The view was not built using a GUI builder plug-in 21 * (but may want to consider doing so in the future), and the controller uses listeners to control how the view and data act. 22 * 19 * This class contains the view and controller for the Login screen. The view 20 * was not built using a GUI builder plug-in (but may want to consider doing so 21 * in the future), and the controller uses listeners to control how the view and 22 * data act. 23 * 23 24 * @author Vincent 24 25 */ 25 26 public class Login extends JFrame { 27 26 public class Login extends JFrame 27 { 28 28 private Box login; 29 29 private JTextField userNameField; 30 30 private JTextField passwordField; 31 32 public Login() { 31 public static String kNamePrompt = "Enter your name"; 32 33 public Login() 34 { 33 35 initView(); 34 36 } 35 36 private ActionListener newEnterActionListener(){ 37 return new ActionListener() { 38 public void actionPerformed(ActionEvent e) { 37 38 private ActionListener newEnterActionListener() 39 { 40 return new ActionListener() 41 { 42 public void actionPerformed(ActionEvent e) 43 { 39 44 setVisible(false); 40 ScreenManager.setUserName(userNameField.getText()); 45 // Check if user provided a username JD 46 String userEntry = userNameField.getText(); 47 if (userEntry.equals(kNamePrompt)) 48 { 49 ScreenManager.setUserName("Anonymous Trainee"); 50 } 51 else 52 { 53 ScreenManager.setUserName(userEntry); 54 } 41 55 ScreenManager.openCADMenu(); 42 56 ScreenManager.openAssignedIncidents(); … … 44 58 ScreenManager.openPendingIncidents(); 45 59 ScreenManager.openPowerlineUI(); 46 if (!passwordField.getText().equals("Dispatcher")) { 60 if (!passwordField.getText().equals("Dispatcher")) 61 { 47 62 ScreenManager.setDispatcherAuthority(false); 48 63 } … … 50 65 }; 51 66 } 52 53 private ActionListener newExitActionListener(){ 54 return new ActionListener() { 55 public void actionPerformed(ActionEvent e) { 67 68 private ActionListener newExitActionListener() 69 { 70 return new ActionListener() 71 { 72 public void actionPerformed(ActionEvent e) 73 { 56 74 System.exit(0); 57 75 } 58 76 }; 59 77 } 60 61 private void initView(){ 78 79 private void initView() 80 { 62 81 login = new Box(BoxLayout.Y_AXIS); 63 82 login.setAlignmentX(LEFT_ALIGNMENT); … … 78 97 79 98 JLabel title = new JLabel(); 80 title.setText("Inform CAD 5.3 Patch 5"); 99 // Check if we are running from a jar to put message from manifest into title 100 Package clientpkg = Login.class.getPackage(); 101 String builddate = clientpkg.getImplementationVersion(); 102 String version = ""; 103 if (builddate != null) 104 { 105 version = " (build " + builddate + ")"; 106 } 107 else // We're running from a dev environment 108 { 109 version = " 00-00-00 00:00"; 110 } 111 112 title.setText("Inform CAD 5.3 Patch 5 "); 81 113 title.setHorizontalAlignment(SwingConstants.CENTER); 82 114 title.setFont(new Font("Arial", Font.PLAIN, 22)); … … 87 119 blueBackground.add(title); 88 120 121 JLabel builddateLabel = new JLabel(version); 122 builddateLabel.setForeground(Color.WHITE); 123 builddateLabel.setHorizontalAlignment(SwingConstants.CENTER); 124 blueBackground.add(builddateLabel); 125 89 126 Box leftBox = new Box(BoxLayout.Y_AXIS); 90 127 leftBox.setMaximumSize(new Dimension(350, 50)); … … 95 132 JLabel userNameLabel = new JLabel("User name "); 96 133 userNameLabel.setForeground(Color.WHITE); 97 userNameField = new JTextField( "Enter your name");134 userNameField = new JTextField(kNamePrompt); 98 135 Box userNameBox = new Box(BoxLayout.X_AXIS); 99 136 userNameBox.setAlignmentX(LEFT_ALIGNMENT); … … 105 142 JLabel passwordLabel = new JLabel("Password "); 106 143 passwordLabel.setForeground(Color.WHITE); 107 passwordField = new JTextField(" Does not matter");144 passwordField = new JTextField("Not required"); 108 145 Box passwordBox = new Box(BoxLayout.X_AXIS); 109 146 passwordBox.setAlignmentX(LEFT_ALIGNMENT);
Note: See TracChangeset
for help on using the changeset viewer.
