Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java GUI 设计 » SWT  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 请问eclipse上的一个问题(项目急等)
yueguangm





发贴: 9
积分: 0
于 2004-10-09 17:39 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
是关于control控件中的tree的,我需要为树的节点添加listener。
参照例子做,
final Tree tree = new Tree(shell, SWT.MULTI | SWT.BORDER);
tree.setSize(150, 150);
tree.setLocation(5,5);

TreeItem myComp = new TreeItem(tree, SWT.NONE);
myComp.setText("My Computer");
TreeItem netPlaces = new TreeItem(tree, SWT.NONE);
netPlaces.setText("My Network Places");
TreeItem myDocs = new TreeItem(tree, SWT.NONE, 1);
myDocs.setText("My Documents");

TreeItem hardDisk = new TreeItem(myComp, SWT.NONE);
hardDisk.setText("Local Disk (CSmile");
TreeItem floppy = new TreeItem(myComp, SWT.NONE, 0);
floppy.setText("3.5 Floppy (ASmile");
TreeItem hardDisk = new TreeItem(myComp, SWT.NONE);
hardDisk.setText("Local Disk (CSmile");
TreeItem progFiles = new TreeItem(hardDisk, SWT.NONE);
progFiles.setText("Program Files");

tree.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TreeItem[] t = tree.getSelection();
System.out.print("Selection: ");
for(int i = 0; i < t.length; i++) {
System.out.print(t[i].getText() + ", ");
}
System.out.println();
}
});

然而当我点击任一节点时,并没有出来我想要的Selection:...结果程序也不报错也没反应。不知道是什么问题?
请高手指教!




话题树型展开
人气 标题 作者 字数 发贴时间
4126 请问eclipse上的一个问题(项目急等) yueguangm 1140 2004-10-09 17:39
3277 Re:请问eclipse上的一个问题(项目急等) xiaomage234 237 2004-10-30 15:06

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923