I'm really tired so this is probably a really dumb mistake, but I'm having trouble printing my binary search tree. Here's the method that I made to print(it works fine if I use System.out.println, but I want to use JOptionPane) I'm open to any suggestions as to how to make the code better too. Please let me know if you need to see all of my code
Thanks
public void print()
{
JOptionPane.showMessageDialog(null, recprint(root));
}
private void recprint(TreeNode p)
{ // recursively print the tree
if (p == null)
return;
recprint (p.left);
System.out.print(p.key + "\n");
recprint (p.right);
}