문제

It is possible to create a jlabel with an icon so that the icon is aligned right ( right justified ) and the text is left justified. That means, in same label component i want the text to appear at the very left end of label and the icon at the far right.

도움이 되었습니까?

해결책

Standard JLabel cannot make a non-static spacing between icon and text, you can only specify iconTextGap in pixels, icon position relative to text and text alignment.

To make what you want you have a few options:

  1. Use some container with label at left side and icon in a separate label at right side
  2. Create specific JLabel UI that will paint icon in the way you want
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top