11package gov .doe .jgi .boost .ui ;
22
3+ import java .awt .event .ActionEvent ;
4+ import java .awt .event .ActionListener ;
5+
6+ import javax .swing .ButtonGroup ;
37import javax .swing .GroupLayout ;
48import javax .swing .JFrame ;
59import javax .swing .JLabel ;
610import javax .swing .JRadioButton ;
711
12+ import gov .doe .jgi .boost .client .constants .BOOSTConstants ;
13+ import gov .doe .jgi .boost .client .utils .UIUtils ;
814
9- public class UserAuthentication {
1015
11-
16+ public class UserAuthentication implements ActionListener {
17+
18+ private JLabel headingText ;
19+ private JRadioButton buttonLogin ;
20+ private JRadioButton buttonJWT ;
21+ private JRadioButton buttonSignUp ;
22+
1223 public UserAuthentication () {
1324
1425 JFrame jFrame = new JFrame ();
1526 jFrame .setTitle ("Prepare for Synthesis" );
16- jFrame .setResizable (false );
1727 jFrame .setDefaultCloseOperation (JFrame .EXIT_ON_CLOSE );
1828 placeComponents (jFrame );
1929 jFrame .setSize (400 , 200 );
@@ -31,10 +41,19 @@ private void placeComponents(JFrame jFrame) {
3141 layout .setAutoCreateGaps (true );
3242 layout .setAutoCreateContainerGaps (true );
3343
34- JLabel headingText = new JLabel ("Please choose one of the given way to Authenticate your Account:" );
35- JRadioButton buttonLogin = new JRadioButton ("Login" );
36- JRadioButton buttonJWT = new JRadioButton ("Provide your JWT" );
37- JRadioButton buttonSignUp = new JRadioButton ("Sign Up" );
44+ headingText = new JLabel ("Please choose one of the given way to Authenticate your Account:" );
45+ buttonLogin = new JRadioButton ("Login" );
46+ buttonJWT = new JRadioButton ("Provide your JWT token" );
47+ buttonSignUp = new JRadioButton ("Sign Up" );
48+
49+ ButtonGroup group = new ButtonGroup ();
50+ group .add (buttonLogin );
51+ group .add (buttonJWT );
52+ group .add (buttonSignUp );
53+
54+ buttonLogin .addActionListener (this );
55+ buttonJWT .addActionListener (this );
56+ buttonSignUp .addActionListener (this );
3857
3958 layout .setHorizontalGroup (
4059 layout .createParallelGroup (GroupLayout .Alignment .LEADING )
@@ -54,5 +73,20 @@ private void placeComponents(JFrame jFrame) {
5473
5574 jFrame .pack ();
5675 jFrame .setLocationRelativeTo (null );
76+ jFrame .setResizable (false );
5777 }
78+
79+ @ Override
80+ public void actionPerformed (ActionEvent event ) {
81+ Object source = event .getSource ();
82+
83+ if (source == buttonLogin ) {
84+ System .out .println ("Login button is clicked" );
85+ new LoginFrame ();
86+ } else if (source == buttonJWT ) {
87+ new JWTAuthenticationFrame ();
88+ } else if (source == buttonSignUp ) {
89+ UIUtils .openWebPage (BOOSTConstants .SIGNUP_URI );
90+ }
91+ }
5892}
0 commit comments