private class ShowAction implements ActionListener {
@Override
public void actionPerformed(ActionEvent event) {
if(typePanel.getSelection().equals("Confirm")) {
//Confirm: 要显示的信息, 标题, 显示操作的类型, 显示的信息的类型
JOptionPane.showConfirmDialog(OptionDialogFrame.this, getMessage(), "Title",
getType(optionTypePanel), getType(messageTypePanel));
} else if(typePanel.getSelection().equals("Input")) {
if(inputPanel.getSelection().equals("Text field")) {
JOptionPane.showInputDialog(OptionDialogFrame.this, getMessage(), "Title", getType(messageTypePanel));
} else {
JOptionPane.showInputDialog(OptionDialogFrame.this, getMessage(), "Title", getType(messageTypePanel),
null, new String[] {"Yellow", "Blue", "Red"}, "Blue");
}
} else if(typePanel.getSelection().equals("Message")) {
JOptionPane.showMessageDialog(OptionDialogFrame.this, getMessage(), "Title", getType(messageTypePanel));
} else if(typePanel.getSelection().equals("Option")) {
JOptionPane.showOptionDialog(OptionDialogFrame.this, getMessage(), "Title", getType(optionTypePanel),
getType(messageTypePanel), null, getOptions(), getOptions()[0]);
}
}
}
@Override
public void actionPerformed(ActionEvent event) {
if(typePanel.getSelection().equals("Confirm")) {
//Confirm: 要显示的信息, 标题, 显示操作的类型, 显示的信息的类型
JOptionPane.showConfirmDialog(OptionDialogFrame.this, getMessage(), "Title",
getType(optionTypePanel), getType(messageTypePanel));
} else if(typePanel.getSelection().equals("Input")) {
if(inputPanel.getSelection().equals("Text field")) {
JOptionPane.showInputDialog(OptionDialogFrame.this, getMessage(), "Title", getType(messageTypePanel));
} else {
JOptionPane.showInputDialog(OptionDialogFrame.this, getMessage(), "Title", getType(messageTypePanel),
null, new String[] {"Yellow", "Blue", "Red"}, "Blue");
}
} else if(typePanel.getSelection().equals("Message")) {
JOptionPane.showMessageDialog(OptionDialogFrame.this, getMessage(), "Title", getType(messageTypePanel));
} else if(typePanel.getSelection().equals("Option")) {
JOptionPane.showOptionDialog(OptionDialogFrame.this, getMessage(), "Title", getType(optionTypePanel),
getType(messageTypePanel), null, getOptions(), getOptions()[0]);
}
}
}