Ok following the suggestion from another user I have switched over to a GroupBagLayout. Following the java tutorial in hindsight this seems easier. But alas, I have ran into a problem which does not make any sense to me.
See screenshot:
http://img189.imageshack.us/img189/1060/groupbaglayout.png
I have started from a top down approach to make my life easier...What I don't get is why is the grid starting in the middle of the frame???
Code:
//Create Panels and TextBoxes
private Container createContentPane()
{
//Creating main JPanel and setting the layout manager...
JPanel contentPane = new JPanel();
contentPane.setLayout(new GridBagLayout());
GridBagConstraints gridC = new GridBagConstraints();
contentPane.setOpaque(true);
if(shouldFill)
{
//natural Height/width
gridC.fill = GridBagConstraints.HORIZONTAL;
}
//Creating the Incoming data, JTextArea
incDisp = new JTextArea(5, 30);
incDisp.setEditable(false);
incDisp.setLineWrap(true);
incDisp.setWrapStyleWord(true);
JScrollPane incScrollPane = new JScrollPane(incDisp);
//Adding incScrollPane to GridBagLayout
if (shouldWeightX)
{
gridC.weightx = 0.5;
}
gridC.fill = GridBagConstraints.HORIZONTAL;
//gridC.anchor = GridBagConstraints.CENTER;
//gridC.weightx = 0.5;
//gridC.weighty = 1.0;
gridC.gridx = 0;
gridC.gridy = 0;
gridC.gridwidth = 2;
gridC.gridheight = 2;
contentPane.add(incScrollPane, gridC);
//Create JLabel for usrDisp and Adding it to GridBagLayout
JLabel usrLabel = new JLabel("Contacts");
gridC.fill = GridBagConstraints.HORIZONTAL;
gridC.anchor = GridBagConstraints.FIRST_LINE_END;
//gridC.weightx = 0.5;
//gridC.weighty = 0.5;
gridC.gridx = 2;
gridC.gridy = 0;
contentPane.add(usrLabel, gridC);
//Creating the user list, JTextArea
/*usrDisp = new JTextArea(0, 0);
usrDisp.setEditable(false);
usrDisp.setLineWrap(true);
usrDisp.setWrapStyleWord(true);
JScrollPane usrScrollPane = new JScrollPane(usrDisp);
gridC.fill = GridBagConstraints.VERTICAL;
gridC.anchor = GridBagConstraints.LINE_END;
//gridC.weightx = 1.0;
//gridC.weighty = 1.0;
gridC.gridx = 3;
gridC.gridy = 1;
gridC.gridwidth = 0;
gridC.gridheight = 2;
contentPane.add(usrScrollPane, gridC);*/
//Creating the send data, JTextArea
/*senDisp = new JTextArea(4, 30);
senDisp.setEditable(true);
senDisp.setLineWrap(true);
senDisp.setWrapStyleWord(true);
JScrollPane senScrollPane = new JScrollPane(senDisp);
gridC.fill = GridBagConstraints.HORIZONTAL;
gridC.anchor = GridBagConstraints.PAGE_END;
//gridC.weightx = 1.0;
//gridC.weighty = 1.0;
gridC.gridx = 0;
gridC.gridy = 2;
gridC.gridwidth = 3;
contentPane.add(senScrollPane, gridC);*/
//Setting up the layout manager and placing items
/*contentPane.add(incScrollPane, BorderLayout.CENTER);
contentPane.add(senScrollPane, BorderLayout.SOUTH);
contentPane.add(usrScrollPane, BorderLayout.EAST);
contentPane.add(usrLabel);*/
return contentPane;
}
This is what is should look like when it is completed:
http://img268.imageshack.us/img268/2757/grouplayout.png