I have a JLabel with a Icon and text aligned to bottom, the icon is center to the text,
how do i have the Text and the icon aligned to left and the text below the icon.
My current code is as below
label.setIcon(new ImageIcon(fileName));
label.setText("This text is going to be varying size and can be bit long");
label.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
label.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
If you mean someting like this, then I cheated.
Basically, I created two
JLabels on aJPanel. Using aGridBagLayoutI aligned the two labels onto of each other and anchored to theWESTIt would pretty easy to create a custom component for the purpose if you wanted to reuse it.