anged(TreeSelectionEvent e)
{//重写valueChanged方法
DefaultMutableTreeNode cdmtn=(DefaultMutableTreeNode)e.getPath().getLastPathComponent();
NodeValue cnv=(NodeValue)cdmtn.getUserObject();
if(cnv.classCode==0)
{//选中节点是根节点时
cl.show(jpy,"root");
}
else if(cnv.classCode==1)
{//选中节点是分组节点时
String group=cnv.toString();
jlGroup.setText(group);
cl.show(jpy,"group");
}
else if(cnv.classCode==2)
{//选中节点是某一联系人节点时
String sql="select pid,pname,pgender,page,pnumber,pemail,pgroup,ppostalcode,"+
"padress from lxy where uid='"+MainFrame.this.uname+"'and pname='"+cnv.toString()+"'";
setInfo(DButil.getPerInfo(sql));
cl.show(jpy,"Info");
}
else if(cnv.classCode==3)
{//相册预览
jpyview.removeAll();//清空相册预览面板
cl.show(jpy,"tpyl");//显示相册预览面板
viewPic(cdmtn);//预览相册
}
else if(cnv.classCode==4)
{//图片明细
cl.show(jpy,"tpmx");//显示图片明细面板
NodeValue pnv=(NodeValue)((DefaultMutableTreeNode)cdmtn).getUserObject();
detailPic(pnv.value);//点击某一张图片
}
}
}
);
jspOuter.setDividerLocation(46);
jspOuter.setTopComponent(jps);
jspOuter.setBottomComponent(jspInner);
jspInner.setDividerLocation(100);
jspOuter.setDividerSize(0);
jspInner.setDividerSize(4);
this.add(jspOuter);
this.addWindowListener(
new WindowAdapter()
{
public void WindowClosing(WindowEvent e)
{
MainFrame.this.hide();
}
}
);
//设置主窗体的图标、标题、大小以及可见性
Image image=Toolkit.getDefaultToolkit().getImage("img/link.png");//得到图标对象
this.setIconImage(image);
this.setTitle(uname+"的通讯录");
this.setBounds(300,200,600,550);
this.setVisible(true);
}
public void initJps()
{//界面上半部分的初始化
jps.setLayout(null);
jba.setBounds(5,10,80,26);
jba.addActionListener(this);
jps.add(jba);
jbs.setBounds(90,10,80,26);
jbs.addActionListener(this);
jps.add(jbs);
jtfs.setBounds(175,10,120,26);
jtfs.addActionListener(this);
jps.add(jtfs);
jrbxm.setBounds(5,3,50,26);
jrbxm.addItemListener(this);
bg.add(jrbxm);
jpbr.add(jrbxm);
jrbbh.setBounds(60,3,50,26);
jrbbh.addItemListener(this);
bg.add(jrbbh);
jpbr.add(jrbbh);
jpbr.setBounds(300,10,200,26);
jps.add(jpbr);
}
public void initTree()//用树状结构实现联系人及其相片的管理,显示等功能
{//初始化树
jtz.setModel(dtm);
jtz.setExpandsSelectedPaths(true);
jtz.setCellRenderer(dtcr);
ImageIcon icon=new ImageIcon("img/wzk.png");
dtcr.setClosedIcon(icon);
icon=new ImageIcon("img/zk.png");
dtcr.setOpenIcon(icon);
icon=new ImageIcon("img/mzjd.png");
dtcr.setLeafIcon(icon);
Vector
group=DButil.getNode(uname,"uid");
for(int i=0;i {//添加组节点
String s=group.get(i);
DefaultMutableTreeNode dmtnGroup=new DefaultMutableTreeNode(new NodeValue(s,1));
dtm.insertNodeInto(dmtnGroup,root,i);//将分组节点添加到根节点
//添加人名节点
Vector pnode=DButil.getNode(uname,"pname;"+s);
for(String person:pnode)
{
dmtnGroup.add(this.initPerNode(person));//将各个分组下的联系人节点添加到分组节点
}
}
}
public void initJpy()
{//界面右边为卡片布