Skip to content

Commit eff5075

Browse files
committed
improved the window layout of 2fa and secret prompt windows
1 parent 23ea8d3 commit eff5075

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

src/main/java/lol/hyper/customlauncher/accounts/windows/SecretPrompt.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@
2323
import lol.hyper.customlauncher.login.LoginRequest;
2424

2525
import javax.swing.*;
26+
import java.awt.*;
2627

2728
public class SecretPrompt extends JFrame {
2829

2930
public SecretPrompt(String title, Account account) {
3031
JFrame frame = new JFrame(title);
31-
frame.setSize(370, 150);
32+
frame.setSize(170, 120);
3233
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
3334
frame.setResizable(false);
3435
try {
@@ -39,19 +40,18 @@ public SecretPrompt(String title, Account account) {
3940

4041
// GUI elements
4142
JPanel panel = new JPanel();
42-
panel.setLayout(null);
43+
panel.setLayout(new GridBagLayout());
44+
GridBagConstraints gbc = new GridBagConstraints();
45+
gbc.gridwidth = GridBagConstraints.REMAINDER;
46+
gbc.fill = GridBagConstraints.HORIZONTAL;
4347

4448
JLabel secretLabel = new JLabel("Secret Phrase");
4549
JPasswordField secretText = new JPasswordField();
4650
JButton loginButton = new JButton("Login");
4751

48-
secretLabel.setBounds(50, 25, 100, 30);
49-
secretText.setBounds(150, 25, 100, 30);
50-
loginButton.setBounds(50, 75, 100, 30);
51-
52-
panel.add(secretLabel);
53-
panel.add(secretText);
54-
panel.add(loginButton);
52+
panel.add(secretLabel, gbc);
53+
panel.add(secretText, gbc);
54+
panel.add(loginButton, gbc);
5555

5656
// button listeners
5757
loginButton.addActionListener(event -> {

src/main/java/lol/hyper/customlauncher/login/windows/TwoFactorAuth.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class TwoFactorAuth extends JFrame {
2929

3030
public TwoFactorAuth(String title, String banner, String token) {
3131
JFrame frame = new JFrame(title);
32-
frame.setSize(370, 200);
32+
frame.setSize(230, 150);
3333
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
3434
frame.setResizable(false);
3535
try {
@@ -40,7 +40,10 @@ public TwoFactorAuth(String title, String banner, String token) {
4040

4141
// GUI elements
4242
JPanel panel = new JPanel();
43-
panel.setLayout(null);
43+
panel.setLayout(new GridBagLayout());
44+
GridBagConstraints gbc = new GridBagConstraints();
45+
gbc.gridwidth = GridBagConstraints.REMAINDER;
46+
gbc.fill = GridBagConstraints.HORIZONTAL;
4447

4548
JLabel text = new JLabel("<html>" + banner + "</html>");
4649
JTextField userAuthCode = new JTextField();
@@ -58,14 +61,9 @@ public void keyTyped(KeyEvent e) {
5861

5962
JButton loginButton = new JButton("Submit");
6063

61-
userAuthCode.setMaximumSize(new Dimension(50, 25));
62-
text.setBounds(30, 15, 300, 30);
63-
userAuthCode.setBounds(30, 50, 70, 30);
64-
loginButton.setBounds(30, 85, 100, 30);
65-
66-
panel.add(text);
67-
panel.add(userAuthCode);
68-
panel.add(loginButton);
64+
panel.add(text, gbc);
65+
panel.add(userAuthCode, gbc);
66+
panel.add(loginButton, gbc);
6967

7068
// button listeners
7169
loginButton.addActionListener(event -> {

0 commit comments

Comments
 (0)