大家好我是寻觅;
介绍个东西--SWT 给大家,不知道大家玩过没?
SWT性能远远胜过AWT和SWING,在Eclipse下的Designer比JB强得多,综合起来比C#还强。
Designer for Eclipse3.2.2
http://downloads.instantiations.com/Designer/continuous/latest/Designer_v6.3.1_for_Eclipse3.2.zip如果该地址无法下载,请到
官方网站下载
环境配置参照:
http://www.blogjava.net/lusm/archive/2007/06/22/125866.html包下载
ttp://download.eclipse.org/eclipse/downloads/drops/R-3.2.2-200702121330/download.php?dropFile=swt-3.2.2-win32-win32-x86.zip例子在线
http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/CatalogSWT-JFace-Eclipse.htm例子下载
http://download.eclipse.org/eclipse/downloads/drops/R-3.2.2-200702121330/download.php?dropFile=eclipse-examples-3.2.2-win32.zip给大家两个例子
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import com.swtdesigner.SWTResourceManager;
public class Myapp1 {
private static Text text;
/** *//**
* Launch the application
* @param args
*/
public static void main(String[] args) {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setImage(SWTResourceManager.getImage(Myapp1.class, "/jmapps/images/iconQuery.gif"));
shell.setRegion(null);
shell.setSize(375, 239);
shell.setText("新玩儿");
//
shell.open();
final Button button = new Button(shell, SWT.NONE);
shell.setDefaultButton(button);
button.setImage(SWTResourceManager.getImage(Myapp1.class, "/jmapps/images/audio.gif"));
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
text.setText("当然是没问题咯。");
}
});
button.setText("确定");
button.setBounds(61, 144, 92, 36);
text = new Text(shell, SWT.BORDER);
text.setText("Java写GUI不行?");
text.setFont(SWTResourceManager.getFont("", 20, SWT.NONE));
text.setBackground(SWTResourceManager.getColor(0, 128, 192));
text.setBounds(49, 50, 269, 36);
final Button button_1 = new Button(shell, SWT.NONE);
button_1.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
text.setText("Java写GUI不行?");
}
});
button_1.setImage(SWTResourceManager.getImage(Myapp1.class, "/jmapps/images/audio-disabled.gif"));
button_1.setText(" 重来");
button_1.setBounds(214, 144, 92, 36);
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
上面那个我写着玩的试试而已
地震让大伙知道:居安思危,才是生存之道。
posted on 2007-06-25 15:16
小寻 阅读(1527)
评论(0) 编辑 收藏 所属分类:
j2se/j2ee/j2me