From Java trails SpringLayout (pretty much the first line, actually):
The SpringLayout class was added in JDK version 1.4 to support layout in GUI builders. SpringLayout is a very flexible layout manager that can emulate many of the functions of other layout managers. SpringLayout , however, is very low level and, as such , you should really use it only with a GUI constructor, and not try to code the spring layout manager manually . (Emphasis added.)
I have professionally programmed Java for many years, and even I will not program SpringLayout manually. My recommendation is to use the MigLayout library instead. Their APIs are much simpler to build code and can create very close layouts. I use it for a long time, and I prefer it in everything that I have tried. This is especially nice when used in conjunction with Java BorderLayout because of how space filling works. I highly recommend it.
First of all:
- MigLayout is cell based, but also supports cell splitting and overlapping. If you've ever worked with HTML or Excel, you should know what that means. This is pretty clear.
- The default input method of MigLayout is strings, and they are easy to understand, but they also have a very good API for creating layouts.
- MigLayout supports much more than ever, I will be able to answer the SO question, so follow the link above and read the quick start and trick guide. They are by far the best resource for what you can use in your limitations.
Here is an example using MigLayout to create a similar layout for the example image you provided:
public static void main(String[] args) { JFrame frame = new JFrame("Testing MigLayout"); JPanel contentPane = new JPanel(new MigLayout("fillx")); // Row 1 JLabel areaLabel = new JLabel("Area of Triangle"); areaLabel.setFont(areaLabel.getFont().deriveFont(16.0f)); areaLabel.setHorizontalAlignment(JLabel.CENTER); contentPane.add(areaLabel, "spanx, growx, wrap"); // wrap indicates a new row // Row 2 JLabel side1Label = new JLabel("Side 1:"); contentPane.add(side1Label, "alignx trailing"); JTextField side1Field = new JTextField(); side1Field.setColumns(6); contentPane.add(side1Field, "alignx leading, wrap"); // Row 3 JLabel side2Label = new JLabel("Side 2:"); contentPane.add(side2Label, "alignx trailing"); JTextField side2Field = new JTextField(); side2Field.setColumns(6); contentPane.add(side2Field, "alignx leading, wrap"); // Row 4 JLabel side3Label = new JLabel("Side 3:"); contentPane.add(side3Label, "alignx trailing"); JTextField side3Field = new JTextField(); side3Field.setColumns(6); contentPane.add(side3Field, "alignx leading, wrap"); // Row 5 JButton calculateButton = new JButton("Calculate Area"); contentPane.add(calculateButton, "spanx, growx"); frame.setContentPane(contentPane); // Resizes automatically frame.pack(); // Centers automatically frame.setLocationRelativeTo(null); // Exit when the frame is closed frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
And his conclusion:

Of course, this is not all logic, but it still shows the power of MigLayout. When you start working in more complex applications and want the components to expand and contract with the window, MigLayout works very well. If you've ever used GridBadLayout , you'll notice that MigLayout is just a version of it.
For references that all are separate parts of this, just look at the hype sheet. There is an explanation for every part that I used. In particular, everything that is declared in the MigLayout constructor (here, "fillx" ) is a layout constraint, and everything that is declared in add methods (for example, "spanx" and "wrap" ) are component constraints. There you can practice and experiment more to get only the right combination, which creates a great graphical interface.
However, there are always other, simpler layout managers, such as GridLayout or BoxLayout . For simple applications like yours, these layout managers are great. When you start getting into more intensive applications, I recommend logging into MigLayout. For reading on them I recommend Java trails. There is a visual guide to layouts , and you can use this as a transition point. I recommend sticking with them for manual layout:
BorderLayoutBoxLayoutCardLayoutFlowLayoutGridBagLayoutGridLayout