我在shell中加了一个list,还有两个composite(composite_1,composite_2),其中composite是用stackLayout布局的,然后在list中我加了两个选项:xxxxxx和yyyyyy,我想实现以下功能:
用鼠标点xxxxxx,composite_1出现;点yyyyyy,composite_2出现。
请问这个怎么实现?
还有个问题?
在eclipse中,SWT的Designed能加上鼠标的Listener吗?
谢谢!
用鼠标点xxxxxx,composite_1出现;点yyyyyy,composite_2出现。
请问这个怎么实现?
还有个问题?
在eclipse中,SWT的Designed能加上鼠标的Listener吗?
谢谢!
解决方案 »
- bbs论坛的问题
- Java读取文件乱码,请帮忙
- 我刚学了Java 请问高手接下来 该怎么学习?
- 我以前是学asp.net的,我刚学用Struts的MVC2来做jsp网页,看了很多资料,有些东西很糊涂的,我对MVC2和asp.net中的三层结构的关系的理解如下
- String类的参数传递方式的问题和探讨!(高分)
- 在MyEclipse中运行下面代码出现的错误是:You have an error in your SQL syntax; check the manual t
- 在jbuilder里面如何调试线程?
- 请问在Jbuilder8里面该怎么配置,谢谢!
- 小妹求教各位大哥
- 如何比较两个数的大小,并按从小到大的次序输出。如:double d1=23.4;double d2=35.1;
- 类似dos状态下 如何把手工输入的数字纪录进数组
- 关于页面传值的问题?
http://community.csdn.net/Expert/topic/4350/4350473.xml?temp=.1800501
* 创建日期 2005-10-25
*
* TODO 要更改此生成的文件的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
package eclipse_study;import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Text;
/**
* @author stt
*
* TODO 要更改此生成的类型注释的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
public class StackLayout1 { private org.eclipse.swt.widgets.Shell sShell = null;
private Composite composite = null;
private Composite composite1 = null;
private Button button1 = null;
private Button button2 = null;
private Text text1 = null;
private Text text2 = null;
private StackLayout stackLayout = new StackLayout();
/**
* This method initializes sShell
*/
private void createSShell() {
sShell = new org.eclipse.swt.widgets.Shell();
createComposite();
createComposite1();
sShell.setText("Shell");
sShell.setLayout(new FillLayout());
sShell.setSize(new org.eclipse.swt.graphics.Point(300,200));
}
/**
* This method initializes composite
*
*/
private void createComposite() {
composite = new Composite(sShell, SWT.NONE);
composite.setLayout(stackLayout);
text1 = new Text(composite, SWT.BORDER);
text2 = new Text(composite, SWT.BORDER);
text1.setBounds(new org.eclipse.swt.graphics.Rectangle(28,91,72,20));
text1.setText("text1");
text2.setBounds(new org.eclipse.swt.graphics.Rectangle(35,123,72,20));
text2.setText("text2");
}
/**
* This method initializes composite1
*
*/
private void createComposite1() {
composite1 = new Composite(sShell, SWT.NONE);
button1 = new Button(composite1, SWT.NONE);
button2 = new Button(composite1, SWT.NONE);
button1.setText("button1");
button2.setText("button2");
composite1.setLayout(new RowLayout());
button1.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
System.out.println("widgetSelected()"); // TODO Auto-generated Event stub widgetSelected()
stackLayout.topControl = text1; //将text1框显示
composite.layout(); //将界面刷新一下,否则显示上会没任何反映的
}
});
}
}
这个我好像在《eclipse入门与精通》里看过,我想实现的是list的,不是button的
list怎么用mouselistener实现?
composite1 = new Composite(sShell, SWT.NONE);
list = new List(composite1, SWT.NONE);
list.setBounds(new org.eclipse.swt.graphics.Rectangle(19, 89, 67, 64));
list.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected( org.eclipse.swt.events.SelectionEvent e) {
System.out.println(list.getSelectionIndex());//打印选择列表后的数值
int aaa=list.getSelectionIndex();
if (aaa==0) {//如果选择LIST第一项...
stackLayout.topControl = text; //将text1框显示
composite.layout();
}
else{
stackLayout.topControl = text1; //将text1框显示
composite.layout();
}
}
});
list.add("123", 0); //增加列表内容
list.add("456", 1);
}