目录
第一步:点击help,找到Eclipese MarketPlace
第二步:点击第一个installed,然后会弹出提示,点击confirm
第三步:下载完后,会提示你重新启动该Eclipse,d点击重启
第四步:点击file,点击new,点击other,找到这个,就说明成功了
第一步:点击help,找到Eclipese MarketPlace
第二步:搜WindowBuilder
第3步:点击第一个installed,然后会弹出提示,点击confirm
第4步:下载完后,会提示你重新启动该Eclipse,d点击重启
第四步:点击file,点击new,点击other,找到这个,就说明成功了
来一段代码
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class Test1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Display dis=new Display();//display对象
Shell she=new Shell(dis);//程序主窗体
Button b1=new Button(she,SWT.None|SWT.RIGHT|SWT.BORDER);
b1.setBounds(20,20,90,60);
b1.setText("中文");
FontData font=new FontData();
font.setName("宋体");
font.setHeight(20);
Font fo=new Font(dis,font);
b1.setFont(fo);
Color c1=new Color(dis,0,255,0);
b1.setForeground(c1);
Color c2=new Color(dis,0,0,255);
b1.setBackground(c2);
she.setText("hello World");
she.setBounds(200,200,300,300);
Color col=new Color(255,0,0);
she.setBackground(col);
//打开窗口
she.open();
while(!she.isDisposed()) {//如果主窗体没有关闭则一直循环
if(!dis.readAndDispatch()) {//如果dis不忙
dis.sleep();//休眠
}
}
}
}