//Listener for the preorder button
jbtPreOrder.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e){
key = Integer.parseInt(jtfKey.getText());
if (!tree.isEmpty()){
JOptionPane.showMessageDialog(null, "Enter something in the tree");
}
else {
JOptionPane.showMessageDialog(null, key + " ");
preorder(key.left);
preorder(key.right);
}
}
});
In the preorder it says int cannot be dereferenced even when the variable is global.
Key is a an int and int is a primitive. You cannot call methods on a primitive, only an object. Key should really be a string because you are calling get text and hence retrieving characters and not numbers....