I have 3 JPanels that are in a vertical boxlayout panel inside the WEST of a borderlayout jpanel. the first 2 jpanels are aligned to the left but the last one is not. I am unsure as to why I have tried using the alignment method but it seems to do nothing.
CODE:
public void create(){
JPanel body = new JPanel();
BorderLayout border = new BorderLayout();
body.setLayout(border);
JPanel LEFT = new JPanel();
BoxLayout LV = new BoxLayout(LEFT, BoxLayout.Y_AXIS);
LEFT.setLayout(LV);
JLabel header = new JLabel("PizzaBoy Brewing");
header.setFont(new Font("Serif", Font.BOLD, 40));
header.setForeground(Color.yellow);
JButton Calculate = new JButton("CALCULATE");
JPanel numIngredPanel = numIngredPanel();
JPanel batchSize = batchSize();
JPanel modList = modList();
JPanel ingredList = ingredList();
JPanel batchInfo = batchInfo();
LEFT.add(numIngredPanel);
LEFT.add(batchSize);
LEFT.add(modList);
body.add(header, border.NORTH);
body.add(LEFT, border.WEST);
body.add(Calculate, border.SOUTH);
body.add(ingredList, border.CENTER);
body.add(batchInfo,border.EAST);
//numIngredPanel.setAlignmentX(5);
//batchSize.setAlignmentX(5);
//modList.setAlignmentX(5);
this.add(body);
pack();
revalidate();
}
CODE FOR LIST MODIFIER JPANEL:
public JPanel modList(){
JPanel body = new JPanel();
BoxLayout box = new BoxLayout(body, BoxLayout.Y_AXIS);
body.setLayout(box);
JLabel header = new JLabel();
JLabel note = new JLabel();
header.setText("List Modifier");
note.setText("Note*: removes last field on list.");
LineBorder border = new LineBorder(Color.BLACK);
Border margin = new EmptyBorder(10,10,10,10);
body.setBorder(new CompoundBorder(border,margin));
JButton add = new JButton();
JButton del = new JButton();
add.setText("Add Ingredient");
del.setText("Remove Ingredient");
body.add(header);
body.add(add);
body.add(del);
body.add(note);
//me.add(body);
pack();
revalidate();
return body;
}
