Object[] options = { "OK"};
JPanel messagePanel = new JPanel();
messagePanel.setAlignmentX(0);
messagePanel.setLayout(new GridLayout(2, 1));
messagePanel.add(new JLabel(warningMsg.toString()));
JPanel checkBoxPanel = new JPanel();
JLabel waLabel = new JLabel("Don't tell me again");
waLabel.setForeground(new Color(30, 30, 70));
checkBoxPanel.add(waLabel);
JCheckBox cbox = new JCheckBox();
checkBoxPanel.add(cbox);
messagePanel.add(checkBoxPanel);
int response = JOptionPane.showOptionDialog(null, messagePanel,
"Warning", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
null, options, options[0]);
> If you pass the message to JOptionPane as a string, it will break the string up into logical lines,
Not in my experience, hence the link I provided above which shows how you can force the text to wrap at a certain width.
Maybe you can post your working code if you have a shorter way.