forum

Home / DeveloperSection / Forums / How to work with JCheckBox with Image

How to work with JCheckBox with Image

Anonymous User 2201 04-Feb-2015

How can I have a ceckbox grup with image?

I use:

for (String testata : listaTestate) {
        JCheckBox checkbox = new JCheckBox();
        ImageIcon imgTestata = new ImageIcon("src/img/"+testata+".png");
        checkbox.setName(testata);
        checkbox.setBackground(new Color(194, 169, 221));
        checkbox.setSelected(true);
        testate.add(checkbox);
        JLabel label = new JLabel(imgTestata);
        label.setBackground(new Color(194, 169, 221));
        label.setPreferredSize(new Dimension(500, 50));
        testate.add(label);
    }

but a lot of space between the ImageIcon and the JCheckBox


Updated on 04-Jul-2023
I am a content writter !

Can you answer this question?


Answer

2 Answers

Liked By