java里面JTree显示不出来

packagexiachao.com;importjavax.swing.ImageIcon;importjavax.swing.JFrame;importjavax.s... package xiachao.com;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTree;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;
public class Root extends JFrame implements TreeSelectionListener {
private DefaultMutableTreeNode Pos, JBXX,spzl,khzl,gyszl,YWCL,CaiGCL,rkxx,rkcx,SHpxs,xsxx,xscx,other,YWTJ,kctj,XTWH,TCXT;
private JPanel jp;
private JLabel jl;
private JSplitPane jsp;
private JTree tree;
private JScrollPane jsl;
public Root(){
super("pos信息管理系统");
Pos=new DefaultMutableTreeNode("POS信息管理系统");
JBXX=new DefaultMutableTreeNode("基本信息");
spzl=new DefaultMutableTreeNode("商品资料");
JBXX.add(spzl);
khzl=new DefaultMutableTreeNode("客户资料");
JBXX.add(khzl);
gyszl=new DefaultMutableTreeNode("供应商资料");
JBXX.add(gyszl);
YWCL=new DefaultMutableTreeNode("业务处理");
CaiGCL=new DefaultMutableTreeNode("采购入库");
YWCL.add(CaiGCL);
rkxx=new DefaultMutableTreeNode("入库信息");
CaiGCL.add(rkxx);
rkcx=new DefaultMutableTreeNode("入库查询");
CaiGCL.add(rkcx);
SHpxs=new DefaultMutableTreeNode("商品销售");
YWCL.add(SHpxs);
xsxx=new DefaultMutableTreeNode("销售信息");
SHpxs.add(xsxx);
xscx=new DefaultMutableTreeNode("销售查询");
SHpxs.add(xscx);
other=new DefaultMutableTreeNode("其他库存变动");
YWCL.add(other);
YWTJ=new DefaultMutableTreeNode("业务统计");
kctj=new DefaultMutableTreeNode("库存统计");
YWTJ.add(kctj);
XTWH=new DefaultMutableTreeNode("系统维护");
TCXT=new DefaultMutableTreeNode("退出系统");
Pos.add(JBXX);
Pos.add(YWCL);
Pos.add(YWTJ);
Pos.add(XTWH);
Pos.add(TCXT);
tree =new JTree(Pos);
tree.addTreeSelectionListener(this);
jsl=new JScrollPane(tree);
jsp=new JSplitPane();
jsp.setOneTouchExpandable(true);
jsp.setLeftComponent(tree);
jsp.setDividerLocation(100);
jsp.setDividerSize(5);
jsp.setRightComponent(jp);
jp=new JPanel();
jp.setLayout(null);
jp.setBounds(200,50,400,500);
jp.setVisible(true);
ImageIcon img=new ImageIcon("Ico/POS.jpg");
jl=new JLabel();
jl.setBounds(200,50,400,500);
jl.setIcon(img);
jp.add(jl);
this.setLayout(null);
this.add(jsp);
this.add(jsl);
this.add(jp);
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
this.setBounds(0,0,800,900);
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
this.setVisible(true);
}
public void valueChanged(TreeSelectionEvent e){
TreePath treePath=e.getPath();
DefaultMutableTreeNode selectNode =(DefaultMutableTreeNode)treePath.getLastPathComponent();

}
public static void main(String[] args) {
new Root();
}
}
展开
 我来答
匿名用户
2015-08-20
展开全部

setLayout(null) 后,都要使用setBounds

推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式