0

I'm currently using Luna Eclipse and Windows Builder to create a GUI.

I am using a static layout and have added a JPanel and my question is... How do i set the width of my JPanel to 100% of the window.

My code so far:

JPanel panel = new JPanel();
    panel.setBackground(new Color(30, 144, 255));
    panel.setBounds(0, 0, 643, 54);
    panel.setSize(643,50);
    frame.getContentPane().add(panel);

Using the panel.setSize() i can edit the width, as you can see i have 643. But I want to change this too 100% of the window.

Could someone please explain to me how to do this.

Thanks in advance, Sam

methhead
  • 115
  • 2
  • 12

1 Answers1

0

Use BorderLayout:

frame.getContentPane().add(panel, BorderLayout.PAGE_START);
Patricia
  • 2,885
  • 2
  • 26
  • 32