import javax.swing.JInternalFrame;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.*;/* Used by InternalFrameDemo.java. */
public class MenuTree extends JInternalFrame {
    static int openFrameCount = 0;
    static final int xOffset = 0, yOffset = 0;        JTree tree = new JTree();    public MenuTree() {
        super("菜单 #" + (++openFrameCount),
              true, //resizable
              true, //closable
              true, //maximizable
              true);//iconifiable
        //create menutree.
        getContentPane().add(tree);
        tree.addTreeWillExpandListener(
                                                                        new TreeWillExpandListener() {
                        public void treeWillExpand(TreeExpansionEvent e)
                                                                          throws ExpandVetoException {
                                TreePath path = e.getPath();
                                TreeNode node = (TreeNode)
                                                                path.getLastPathComponent();                                if(node.toString().equals("colors")) {
                                        JOptionPane.showMessageDialog(MenuTree.this,
                                                                "Can't Expand Colors",
                                                                "Expansion Vetoed",
                                                                JOptionPane.INFORMATION_MESSAGE);                                        throw new ExpandVetoException(e);
                                }
                        }
                        public void treeWillCollapse(TreeExpansionEvent e)
                                                                          throws ExpandVetoException {
                                TreePath path = e.getPath();
                                TreeNode node = (TreeNode)
                                                                path.getLastPathComponent();                                if(node.toString().equals("food")) {
                                        JOptionPane.showMessageDialog(MenuTree.this,
                                                                "Can't Collapse Food",
                                                                "Collapse Vetoed",
                                                                JOptionPane.INFORMATION_MESSAGE);                                        throw new ExpandVetoException(e);
                                }
                        }
                });        //...Create the GUI and put it in the window...        //...Then set the window size or call pack...
        setSize(300,600);        //Set the window's location.
        setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
    }
}
getContentPane().add(tree);
这句话的位置写错了