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);
这句话的位置写错了
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);
这句话的位置写错了
解决方案 »
- exe4j用自己精简过的jre打包jar成exe文件,打包成exe之后提示找不到mainclass
- matlab java接口编程
- 关于JXTA中MessageImpl类和MessageElementImpl类的问题
- 在线等待!关于类的问题!!
- ■■如何解析一段XML的字符串"<area id="12345" name="test" top="10"/>"?高分!!!!■■
- 用,号分割的字符串转成数组
- JComboBox + JTable 一问
- java开发Windows桌面应用软件
- 关于Applet的一个小问题,24小时时刻关注!请帮忙!谢了先
- java多线程 关于锁的问题
- 关于java打印的问题--给一串html的String,将它按html的格式打印出来
- 一个applet网络通讯的问题,救救我吧!!!
jokerjava(冷血)的方法是正确的,
public Container getContentPane()
Returns the content pane for this internal frame. Specified by:
getContentPane in interface RootPaneContainer
Returns:
the content pane