Not sure how you can fix the border problem, but to fix the layout, I would just use springlayout. Springlayout is just a way to improve the layout of your elements inside a JPanel. You can learn more about this Java Sun Tutorial.
In particular, you use it by setting where you want your northern, southern, western and eastern borders of each element. To do this, you will need to first remove your tags from the append, so that each of them can be named. Therefore, instead of:
add(new JLabel("Text field:"));
do:
JLabel myLabelName = new JLabel("Text field:"); add(myLabelName);
For each of your items (JLabels, JTextAreas and JTextField). Once this is done, you can easily set the layout.
Springlayout layout = new SpringLayout(); setLayout(layout);
Then for each of the elements you must set any required border. They should be in a certain order South, North, West, then East. Although you do not need to use all four borders if you do not want to. The following is an example of setting up the first text area located on top.
layout.putConstraint(SpringLayout.NORTH, FirstTextAreaName, 10, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, FirstTextAreaName, this.getWidth()/2, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.EAST, FirstTextAreaName, -10, SpringLayout.EAST, this);
This example does not set the south of the text area, but if you want it, this should be the first. The first line sets the north side of the text area 10 pixels from the top. When you set other areas besides the name of the previous (above) area, instead, and say that it is 10 pixels from the south of the previous one:
layout.putConstraint(SpringLayout.NORTH, SecondTextAreaName, 10, SpringLayout.SOUTH, FirstTextAreaName);
The second line in the example above sets the east side of the text area to start halfway through the main panel. The last, third line sets the east side of the text area to 10 pixels on the east side of your main panel.