I was wondering if anybody knew if it was possible to change the background color on the buttons inside a JOptionPane
. I know how to change the entire JO
You can use your own buttons with yours characteristics in showOptionDialog
. I guess it is not the best solution, but it simply works.
JButton button = new JButton("OK");
button.setBackground(Color.BLACK);
button.setForeground(Color.WHITE);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
JOptionPane.getRootFrame().dispose();
}
});
JButton[] buttons = { button };
OptionPane.showOptionDialog(null, "Test Message", "Dialog", JOptionPane.OK_OPTION, JOptionPane.INFORMATION_MESSAGE, new ImageIcon(), buttons, buttons[0]);