怎样在UBUNTU里实现java写的简单SWT程序?

来源:百度知道 编辑:UC知道 时间:2024/06/15 05:30:29
把JAVA程序swt程序在终端实现出来需要构建什么环境?
好吧,我承认这个代码是从WINDOW那里复制过来的
代码:
package com.whut;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class ButtonDemo {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Button Example");
shell.setBounds(100, 100, 200, 100);
shell.setLayout(new FillLayout());

final Button button = new Button(shell, SWT.PUSH);
button.setText("Click Me Now");
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent

装eclipse吧,别用记事本了,多累呀~

org.eclipse.swt要下这个包,并且最好在eclipse中运行。ubuntu下安装吧。

你编译的时候需要加入awt的jar包。
javac -classpath .\awt.jar ButtonDemo.java

使用Swing吧,或者AWT也可以,他们是真正平台无关的。
SWT还是类似WINDOWS的