I need some help here. I am new to the Java GUI world.
I have an existing JPanel. For one of the rows I need to have a label followed by a text box, then followed by another label, and another text box. Do I need to add another jpanel within the row somehow to get several text boxes/labels in that row?
Here is what I have so far:
public void addComponents() {
this.setFrameIcon(icon);
lCompanyName = new JLabel("Company");
lPhoneNumber = new JLabel("Phone");
lFullName = new JLabel("FullName");
lAddress1 = new JLabel("Address 1");
lAddress2 = new JLabel("Address 2");
lCity = new JLabel("City");
lState = new JLabel("State");
lZip = new JLabel("Zip");
JPanel labelPane = new JPanel();
labelPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
labelPane.setLayout(new GridLayout(0, 1, 20, 10));
labelPane.add(lCompany);
labelPane.add(lPhone);
labelPane.add(lFullName);
JPanel labelPane2 = new JPanel();
labelPane2.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
labelPane2.setLayout(new GridLayout(0, 1, 20, 10));
labelPane2.add(lAddress1);
labelPane2.add(lAddress2);
labelPane2.add(lCity);
labelPane2.add(lState);
labelPane2.add(lZip);
}
What I really want is to have the city state and zip on the same line. Can someone offer some advice? Thanks in advance.
I have an existing JPanel. For one of the rows I need to have a label followed by a text box, then followed by another label, and another text box. Do I need to add another jpanel within the row somehow to get several text boxes/labels in that row?
Here is what I have so far:
public void addComponents() {
this.setFrameIcon(icon);
lCompanyName = new JLabel("Company");
lPhoneNumber = new JLabel("Phone");
lFullName = new JLabel("FullName");
lAddress1 = new JLabel("Address 1");
lAddress2 = new JLabel("Address 2");
lCity = new JLabel("City");
lState = new JLabel("State");
lZip = new JLabel("Zip");
JPanel labelPane = new JPanel();
labelPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
labelPane.setLayout(new GridLayout(0, 1, 20, 10));
labelPane.add(lCompany);
labelPane.add(lPhone);
labelPane.add(lFullName);
JPanel labelPane2 = new JPanel();
labelPane2.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
labelPane2.setLayout(new GridLayout(0, 1, 20, 10));
labelPane2.add(lAddress1);
labelPane2.add(lAddress2);
labelPane2.add(lCity);
labelPane2.add(lState);
labelPane2.add(lZip);
}
What I really want is to have the city state and zip on the same line. Can someone offer some advice? Thanks in advance.