Users Pricing

forum

Home Forums How to work with JCheckBox with Image – MindStick

How to work with JCheckBox with Image

Anonymous User 2694 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


2 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md