The title says it all. I'm attempting to add a checkbox with both text and an icon displayed next to the checkbox. Here is my class code:
public class MyDialog extends JDialog
{
public MyDialog(Dialog owner, String title)
{
super(owner, title, true);
JPanel mainPanel = new JPanel(new FlowLayout());
JCheckBox box = new JCheckBox();
box.setIcon(new ImageIcon("path/to/icon.svg"));
box.setText("Checkbox");
mainPanel.add(box);
this.add(mainPanel);
this.setSize(new Dimension(500, 500));
this.setVisible(true);
}
}
I would have expected that, upon construction of a new MyDialog
instance, it would display the icon, some text and, well, a checkbox. However, only the icon and the text are displayed. Am I missing something here? Thanks!