|
| 1 | +package gov.doe.jgi.boost.ui; |
| 2 | + |
| 3 | +import javax.swing.GroupLayout; |
| 4 | +import javax.swing.JButton; |
| 5 | +import javax.swing.JFrame; |
| 6 | +import javax.swing.JLabel; |
| 7 | +import javax.swing.JPasswordField; |
| 8 | +import javax.swing.JTextField; |
| 9 | +import javax.swing.SwingConstants; |
| 10 | + |
| 11 | +public class JWTAuthenticationFrame { |
| 12 | + |
| 13 | + public JWTAuthenticationFrame(){ |
| 14 | + JFrame frame = new JFrame("JWTAuthentication"); |
| 15 | + frame.setSize(300, 150); |
| 16 | + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
| 17 | + placeComponents(frame); |
| 18 | + frame.setVisible(true); |
| 19 | + } |
| 20 | + |
| 21 | + private static void placeComponents(JFrame jFrame) { |
| 22 | + |
| 23 | + GroupLayout layout = new GroupLayout(jFrame.getContentPane()); |
| 24 | + jFrame.getContentPane().setLayout(layout); |
| 25 | + |
| 26 | + layout.setAutoCreateGaps(true); |
| 27 | + layout.setAutoCreateContainerGaps(true); |
| 28 | + |
| 29 | + JLabel jWTTokenText = new JLabel("Please peovide your JWT Token:"); |
| 30 | + JTextField tokenText = new JTextField(25); |
| 31 | + JButton submitButton = new JButton("Submit"); |
| 32 | + JButton cancelButton = new JButton("Cancel"); |
| 33 | + |
| 34 | + layout.setHorizontalGroup(layout.createSequentialGroup() |
| 35 | + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) |
| 36 | + .addComponent(jWTTokenText) |
| 37 | + .addComponent(cancelButton)) |
| 38 | + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)) |
| 39 | + .addComponent(tokenText) |
| 40 | + .addComponent(submitButton) |
| 41 | + ); |
| 42 | + |
| 43 | + // we would like the buttons to be always the same size |
| 44 | + layout.linkSize(SwingConstants.HORIZONTAL, cancelButton, submitButton); |
| 45 | + |
| 46 | + layout.setVerticalGroup(layout.createSequentialGroup() |
| 47 | + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) |
| 48 | + .addComponent(jWTTokenText) |
| 49 | + .addComponent(tokenText)) |
| 50 | + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) |
| 51 | + .addComponent(cancelButton) |
| 52 | + .addComponent(submitButton)) |
| 53 | + ); |
| 54 | + |
| 55 | + jFrame.pack(); |
| 56 | + jFrame.setLocationRelativeTo(null); |
| 57 | + jFrame.setResizable(true); |
| 58 | + } |
| 59 | +} |
0 commit comments