ALI
ALI

Reputation: 339

How to add more than one button in Border Layout

This is the Picture of Border Layout enter image description here

I want to add Three buttons at Page_End. is it possible ? and how ?

Note:I cant change layout. else i have to change so much code.

Upvotes: 2

Views: 1386

Answers (1)

tokosh
tokosh

Reputation: 1836

  • Add a JPanel (or Panel) on PAGE_END
  • Use some layout on it (again BorderLayout for example).
  • Add some other components (like buttons) on that JPanel.

** Sample code as requested **

JPanel panel = new JPanel();
JButton button1 = new JButton("Bottom Left");
JButton button2 = new JButton("Bottom Right");
panel.setLayout(new BorderLayout());
panel.add(button1, BorderLayout.LINE_START);
panel.add(button2, BorderLayout.LINE_END);

pane.add(panel, BorderLayout.LINE_END);

Upvotes: 4

Related Questions