JOptionPane doesnt seem to be working...
Code:
//Create JButton named "NewTree"
JButton NewTree = new JButton("Create a new tree");
//Add action Listener
NewTree.addActionListener (new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
Object[] options = {"Strings", "Integers"};
int n = JOptionPane.showOptionDialog(null, "Which type of data will you be using in your tree?", "Data Type?", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, options, options [2]);
}
});
Jcreator seems to think that the error seems to be on this this part of the code...
Code:
int n = JOptionPane.showOptionDialog
the error message is...
showOptionDialog(java.awt.Component,java.lang.Object,java.lang.String,int,int,javax.swing.Icon,java.lang.Object[],java.lang.Object) in javax.swing.JOptionPane cannot be applied to (<nulltype>,java.lang.String,java.lang.String,int,int,java.lang.Object[],java.lang.Object)
Re: JOptionPane doesnt seem to be working...
That is because after the two 'int' arguments you need to have an Icon object, or pass in 'null'. The other problem, once you get that to compile, is that you are accessing options[2]. Java arrays are 0 indexed. You have two options and they are accessed via: options[0] for the first one and options[1] for the second.
Re: JOptionPane doesnt seem to be working...
thanks for the help, that fixed it, im an idiot for not seeing that myself actually... sorry
Re: JOptionPane doesnt seem to be working...
No problem, when dealing with method calls that take a large amount of parameters, that happens quite often. :wave: