kina
kina

Reputation: 45

BorderLayout with jlabels side by side

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

Answers (1)

rdonuk
rdonuk

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

Related Questions