Hey I made a custom JOptionPane that shows multiple custom buttons
String [] codeVlakken = {"Kleur 1", "Kleur 2", "Kleur 3", "Kleur 4" };
JOptionPane.showOptionDialog(null, code , "Cheat menu", JOptionPane.YES_NO_OPTION,
JOptionPane.PLAIN_MESSAGE, null, codeVlakken, "" );
So in the first line I defined what is in my array and on the second line at the end I placed my array name so it will fill it up with my custom named buttons.
Now I want to give each custom button a different color, how can I call "Kleur 1" for example from it?
Thanks in advance
The options
parameter takes a type of Object[]
Instead of using an array of String
s, try using an array of JButton
s.
This would allow you to create and define the properties of buttons before you add then to the dialog
Updated
JButton [] codeVlakken = {JButton("Kleur 1")};
JOptionPane.showOptionDialog(null, code , "Cheat menu", JOptionPane.YES_NO_OPTION,
JOptionPane.PLAIN_MESSAGE, null, codeVlakken, "" );