The JLabel constructor you are using is JLabel(String label, int horizontalAlignement)
.
As defined in the javadoc, this int should be only in certain values:
JLabel public JLabel(String text, int horizontalAlignment)
Creates a JLabel instance with the
specified text and horizontal
alignment. The label is centered
vertically in its display area.
Parameters:
text - The text to be displayed by the label.
horizontalAlignment - One of the following constants defined in SwingConstants: LEFT, CENTER, RIGHT, LEADING or TRAILING.
This value sets where your text is aligned, inside the JLabel. You can't use "SOUTH" here, and this is why you get the "InvalidArgument" exception.
If you want to make your text on the bottom of the label, you have to use setVerticalAlignment(int), with Swingconstants.BOTTOM
. That supposes that your label is centered and will potentially take a wide height on your panel.
If you use a BorderLayout for this panel, you might want to try to add your label with BorderLayout.SOUTH
, as hint for the layout manager. This will stick the label to the bottom part, and it will have a minimal height (the one necessary to display the text). In this case, the vertical alignment of the text doesn't really matter.