eclipse快速导入swt包

 

目录

第一步:点击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();//休眠
			}
		}
	}

}

 

 

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值