0

I have a JCheckBox with a custom icon. The dimensions of the icon are 32x32 pixels.

When I set some text with horizontal alignment RIGHT, the text is not respecting the icon's width.

screenshot of problem

enter image description here

How can I make sure the text does not overlap with the icon and instead be layout next to the icon?

My checkbox is rather straightforward:

JCheckBox cbx = new JCheckBox(new ImageIcon(getClass().getResource(pathToFile)));
cbx.setText("some label");

Thanks.

Frakcool
  • 10,915
  • 9
  • 50
  • 89
  • 2
    For better reproduction of your problem please provide a [SSCCE](http://sscce.org). – Sergiy Medvynskyy Jan 05 '16 at 12:36
  • Trying to build a SSCCE helped. My problem seems to be specific to MPS, where I encounter it when I integrate a custom JCheckBox into my language editor. SInce I cannot reproduce the issue in a standalone Java application, I assume it is a layout issue within MPS. I will follow up on that in the MPS forum. Thanks. – Robert Walter Jan 05 '16 at 13:24
  • In case someone wants to follow the breadcrumbs, I asked the question in the MPS forum now: http://forum.jetbrains.com/thread/Meta-Programming-System-5050 – Robert Walter Jan 05 '16 at 13:36

0 Answers0