Align icon and JCheckbox in JPopupmenu

后端 未结 2 1507
傲寒
傲寒 2021-01-19 03:49

I have a Problem with some icons and check-boxes in a JPopupMenu. The Check-boxes and Icons are not aligned

The Items are created like:



        
2条回答
  •  遥遥无期
    2021-01-19 04:21

    Have a look at this, in order to achieve what you wanted, I did this,

    JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem("Check Me", null, true);
    cbmi.setMargin(new java.awt.Insets(5, 25, 5, 5));
    cbmi.setIconTextGap(15);
    cbmi.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
    helpMenu.add(cbmi);
    

    And here is the OUTPUT of the said thingy :

    enter image description here

提交回复
热议问题