Iām in the early stages of creating a program for working with the Employee / Customer system, right now I just created a GUI for logging in, but I have a little problem with
setLocation();
method. I set it to 250, 250, but it makes the height of my GUI absolutely nuts. My code is below if anyone can fix this.
import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Main extends JFrame { private static final int HEIGHT = 1003; private static final int WIDTH = 400; JTextField _uid = new JTextField(10); JPasswordField _pwd = new JPasswordField(10); JButton _login = new JButton("Login"); JButton _reset = new JButton("Reset"); public Main() { super("Login - Durptech"); Container pane = getContentPane(); setLayout(new FlowLayout()); add(new JLabel("User ID:")); add(_uid); add(new JLabel("Password:")); add(_pwd); add(_login); add(_reset); _reset.addActionListener(new ResetButtonHandler()); setSize(WIDTH, HEIGHT); setVisible(true); setResizable(false); setLocation(250, 250); setDefaultCloseOperation(EXIT_ON_CLOSE); } private class ResetButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { _uid.setText(""); _pwd.setText(""); _uid.requestFocusInWindow(); } } public static void main(String[] args) { new Main(); } }
source share