assert mainClasses != null;
String mainClass = null;
final JButton okButton = new JButton(NbBundle.getMessage(MainClassWarning.class, "LBL_MainClassWarning_ChooseMainClass_OK")); // NOI18N
okButton.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(MainClassWarning.class, "AD_MainClassWarning_ChooseMainClass_OK"));
final MainClassWarning panel = new MainClassWarning(NbBundle.getMessage(MainClassWarning.class, "CTL_FileMultipleMain", file.getNameExt()), mainClasses);
Object[] options = new Object[]{
okButton,
DialogDescriptor.CANCEL_OPTION
};
panel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
if (e.getSource() instanceof MouseEvent && MouseUtils.isDoubleClick(((MouseEvent) e.getSource()))) {
// click button and the finish dialog with selected class
okButton.doClick();
} else {
okButton.setEnabled(panel.getSelectedMainClass() != null);
}
}
});
DialogDescriptor desc = new DialogDescriptor(panel,
NbBundle.getMessage(MainClassWarning.class, "CTL_FileMainClass_Title"), // NOI18N
true, options, options[0], DialogDescriptor.BOTTOM_ALIGN, null, null);
desc.setMessageType(DialogDescriptor.INFORMATION_MESSAGE);
Dialog dlg = DialogDisplayer.getDefault().createDialog(desc);
dlg.setVisible(true);
if (desc.getValue() == options[0]) {
mainClass = panel.getSelectedMainClass();
}
dlg.dispose();
return mainClass;
}