Reputation: 45
How can I make 2 labels align with each other in a borderLayout.
panel.add(new JLabel(new ImageIcon("123.jpg"), SwingConstants.LEFT),BorderLayout.NORTH);
panel.add(new JLabel(new ImageIcon("123.jpg")), BorderLayout.NORTH);
I want it so that these 2 images are beside each other in the north side
Upvotes: 0
Views: 1320
Reputation: 3956
Use another panel for hold labels.
JPanel labelPanel = new JPanel();
labelPanel.add(new JLabel(new ImageIcon("123.jpg"));
labelPanel.add(new JLabel(new ImageIcon("123.jpg"));
panel.add(labelPanel, BorderLayout.NORTH);
Upvotes: 2