I am developing a Java application and would like some help in positioning some Labels and TextFields.
Here is my code:
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JComboBox;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JTextField;
import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.FlowLayout;
public class AuctionClient
{
public AuctionClient()
{
JFrame GUIFrame = new JFrame();
JPanel GUIPanel = new JPanel();
JLabel LabelUserName = new JLabel("UserName:");
JTextField TextFieldUserName = new JTextField(" ");
JLabel LabelPassword = new JLabel("Password:");
JTextField TextFieldPassword = new JTextField(" ");
GUIFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GUIFrame.setTitle("Auction Client");
GUIFrame.setSize(500,250);
GUIFrame.setLocationRelativeTo(null);
GUIPanel.add(LabelUserName);
GUIPanel.add(TextFieldUserName);
GUIPanel.add(LabelPassword);
GUIPanel.add(TextFieldPassword);
GUIFrame.add(GUIPanel, BorderLayout.NORTH);
GUIFrame.setVisible(true);
}
}
With the above code, the LabelPassword and TextFieldPassword is on the same line as the LabelUsername and TextFieldUsername. Can I please have some help to position the LabelPassword and TextFieldPassword on a new line. Is it possible to specify X,Y coordinates to position objects on a JFrame?
Here is an image to show you how the objects are currently being shown: