I'm making a GUI where there's a question on the top and a JFormattedTextField under it. The thing is that the input field starts in the center of the window; it looks very awkward. I want it to start from the far left. Here is the code, I bolded my attempt to fix it and I'm unsure why it doesn't work. I also want to align the button (randomBtn) to the left, it appears in the center.
JFrame gridPrompt = new JFrame("Select The Size of The Grid");
JLabel labelOne = new JLabel("Please Enter A Number Between 1-10 Below:");
JButton randomBtn = new JButton("Random");
JFormattedTextField rowsInput = new JFormattedTextField(NumberFormat.getNumberInstance());
//Makes the input box 10 columns wide
rowsInput.setColumns(10);
gridPrompt.setLayout(new GridBagLayout());
GridBagConstraints layoutObj = new GridBagConstraints();
layoutObj.gridx = 0;
layoutObj.gridy = 0;
layoutObj.insets = new Insets(5, 5, 5, 5);
gridPrompt.add(labelOne, layoutObj);
layoutObj.gridx = 0;
layoutObj.gridy = 1;
layoutObj.insets = new Insets(5, 5, 5, 5);
====>>> rowsInput.setHorizontalAlignment(JTextField.LEFT); <<<======= THIS LINE DOESNT DO ANYTHING
gridPrompt.add(rowsInput, layoutObj);
//Button configuration
layoutObj.gridx = 0;
layoutObj.gridy = 2;
layoutObj.insets = new Insets(5, 5, 5, 5);
gridPrompt.add(randomBtn, layoutObj); <<======== I WANT THIS TO FLOAT LEFT TOO