Search code examples
jlabelimageicon

JLabel ImageIcon position


I have a JLabel with an ImageIcon, which I put by using the setIcon() function in JLabel. The ImageIcon then comes up, sitting to the left of the text of my JLabel. Is it possible to have the ImageIcon be on the right of the text?


Solution

  • Let's say the label is called "label" - Then use:

    label.setHorizontalTextPosition(JLabel.LEFT);
    

    That should work.