As described in the title. I have two JPanels one on top of the other using BorderLayout() .
import java.awt.*; import javax.swing.*; public class myForm(){ public static void main(String[] args) { JFrame myFrame = new JFrame("SingSong"); myFrame.setLocation(100,100); myFrame.setSize(new Dimension(1024,800)); myFrame.setLayout(new BorderLayout()); JPanel jp = new JPanel(); jp.setBackground(new Color(0x00FF00FF)); JPanel jp2 = new JPanel(new BorderLayout()); jp2.setBackground(new Color(0x00000000)); jp.setPreferredSize(new Dimension(100,400)); jp2.setPreferredSize(new Dimension(100,400)); jp2.setLocation(0, 512); myFrame.add(jp2, BorderLayout.SOUTH); myFrame.add(jp, BorderLayout.NORTH); } }
Each of them takes half, but how can I configure it so that they always occupy half of the JFrame each, even when resizing? (PS I usually use the best variable names, I just hacked it like SSCCE)
yoonsi
source share