我在JOptionPane.showConfirmDialog中有一个JPanel。我想将“是/否/取消”按钮更改为自定义值,但不确定如何。
private void displayGUI(String msg) {
UIManager.put("OptionPane.okButtonText", "SNOOZE");
final int selectedVal = JOptionPane.showConfirmDialog(null, getPanel(msg));
if (selectedVal == JOptionPane.OK_OPTION){
System.out.println("Ok button has been pressed.");
}
}
private JPanel getPanel(String msg) {
JPanel panel = new JPanel();
JLabel label = new JLabel (msg, JLabel.CENTER);
label.setFont (label.getFont ().deriveFont (32.0f));
panel.setPreferredSize(new Dimension(500,500));
panel.add(label);
return panel;
}
我尝试使用UIManager,但没有成功。