Search code examples
javaswingjlabelswingx

Display text over the icon in JXLabel


I'm using SwingX label for a image select/preview.
I need to show both text and icon together but when I set icon the text disappear!
How can I show text over the icon on a JXLabel?

Thanks


Solution

  • there no issue with that, there are two ways

    1.correct way (implemented in the API, good habits, blablabla)

    JLabel.setHorizontalTextPosition(JLabel.CENTER); 
    // search for equivalent in SwingX
    

    2.crazy way to set proper LayoutManager for JXLabel and put there another JXLabel to the desired coordinates Location