Topic: 请问eclipse上的一个问题(项目急等) |
Print this page |
1.请问eclipse上的一个问题(项目急等) | Copy to clipboard |
Posted by: yueguangm Posted on: 2004-10-09 17:39 是关于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 (C"); TreeItem floppy = new TreeItem(myComp, SWT.NONE, 0); floppy.setText("3.5 Floppy (A"); TreeItem hardDisk = new TreeItem(myComp, SWT.NONE); hardDisk.setText("Local Disk (C"); 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:...结果程序也不报错也没反应。不知道是什么问题? 请高手指教! |
2.Re:请问eclipse上的一个问题(项目急等) [Re: yueguangm] | Copy to clipboard |
Posted by: xiaomage234 Posted on: 2004-10-30 15:06 我没遇到你这样的问题,你看看我的代码吧,(对了,你的驱动器c好象写重复了,不知道是不是这个原因) Selection: My Computer, Selection: My Documents, Selection: My Network Places, Selection: My Network Places, My Documents, Selection: My Computer, My Network Places, My Documents, |
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 |