testButton = new JButton("createCustomDialog w/ ActionCommands, Cancel");
testButton.setToolTipText("Create dialog then set an array of action commands.");
testButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ActionCommand save = new ActionCommand("Save and Exit") {
public void run() {
ModalDialog.showPlainDialog("Saving");
}
public boolean isSuccessful() {
return true;
}
};
ActionCommand lefty = new ActionCommand("Lefty") {
public void run() {
ModalDialog.showPlainDialog("Lefty");
}
public boolean isSuccessful() {
return false;
}
};
ActionCommand[] list = { lefty, save };
ModalDialog md = ModalDialog.createCustomDialog("Custom Test", list);
final Action action = md.getNamedAction("Lefty");
JButton button = new JButton("Toggle Lefty");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
action.setEnabled(!action.isEnabled());
}
});
md.showDialog(button);
}
});
p.add(testButton);
testButton = new JButton("createCustomDialog w/ ActionCommands, No Cancel");
testButton.setToolTipText("Create dialog with optional cancel, then set an array of action commands.");
testButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ModalDialog.showWarningDialog("To be implemented.");
}
});
p.add(testButton);
// Placeholder to skip a cell.
p.add(new JLabel());
testButton = new JButton("createCustomDialog w/ Strings, Cancel");
testButton.setToolTipText("Create dialog with an array of strings.");
testButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ModalDialog.showWarningDialog("To be implemented.");
}
});
p.add(testButton);
testButton = new JButton("createCustomDialog w/ Strings, No Cancel");
testButton.setToolTipText("Create dialog with optional cancel and an array of strings.");
testButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ModalDialog.showWarningDialog("To be implemented.");
}
});
p.add(testButton);
testButton = new JButton("createOKDialog w/ ActionCommand");
testButton.setToolTipText("Create dialog then set an action command.");
testButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final JTextField p = new JTextField("(enter a number)");
ActionCommand okPassword = new ActionCommand("Enter") {
boolean successful = true;
public void run() {
try {
Integer.parseInt(p.getText());
successful = true;