final String title = "Exit";
final String instruction = "Exiting TaskDialog";
final String text = "Are you sure you want to exit ?";
TaskDialog dlg = new TaskDialog( null, title);
dlg.setInstruction(instruction);
dlg.setText(text);
dlg.setIcon(TaskDialog.StandardIcon.QUESTION);
final JLabel commentTitle = new JLabel("Tell us why you are exiting TaskDialog");
final JTextArea comment = new JTextArea(5, 100);
final JCheckBox disableComments = new JCheckBox("don't ask me to comment again");
disableComments.setOpaque(false);
final JPanel panel = new JPanel(new BorderLayout());
panel.setOpaque(false);
panel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
panel.add(commentTitle, BorderLayout.NORTH);
panel.add(new JScrollPane(comment));
panel.add(disableComments, BorderLayout.SOUTH);
dlg.getDetails().setExpandableComponent(panel);
// dlg.getDetails().setExpanded(true);
dlg.getDetails().setAlwaysExpanded(true);
dlg.setCommands(
TaskDialog.StandardCommand.OK.derive(TaskDialog.makeKey("Yes")),
TaskDialog.StandardCommand.CANCEL.derive(TaskDialog.makeKey("No")) );
dlg.getFooter().setCheckBoxText( "don't ask me again" );
dlg.getFooter().setCheckBoxSelected(false);
final TaskDialog.Command result = dlg.show();
boolean exit = result.equals(TaskDialog.StandardCommand.OK);
final boolean disableConfirm = dlg.getFooter().isCheckBoxSelected();
System.out.println("exit = " + exit);
System.out.println("disableConfirm = " + disableConfirm);
System.out.println("disableComments = " + disableComments.isSelected());
System.out.println("comment = " + comment.getText());