xia__nested_class.rar

  • millioq
    了解作者
  • Java
    开发工具
  • 2KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 1
    下载次数
  • 2018-01-28 22:04
    上传日期
手把手叫你做Eclipse界面,这是一个使用swt作成的界面效果,大家试试看,自己做的哦
xia__nested_class.rar
  • t9JQQ.java
    9.8KB
内容介绍
/* * Created on 2005-7-12 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ package elink.dsms.test.bo; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.custom.StackLayout; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; public class QQ { /** * 为了自定义监听器类MyMouseLister中的代码能访问到以下对象,故将这些对象定义成 类的实例变量 */ private StackLayout stackLayout = new StackLayout(); private Composite yourDataComp; private Composite otherComp; private List selectList; private Composite rightComp; /** * 由于自定义方法较多程序较长,这次的主程序框架选择了Eclipse“新建”向导的第二种: “public open() mothd” */ public static void main(String[] args) { try { QQ window = new QQ(); window.open(); } catch (Exception e) { e.printStackTrace(); } } public void open() { Display display = Display.getDefault(); Shell shell = new Shell(); shell.setSize(550, 350); shell.setText("个人设置"); shell.setLayout(new GridLayout()); { //分割窗口 SashForm sashForm = new SashForm(shell, SWT.BORDER); sashForm.setLayoutData(new GridData(GridData.FILL_BOTH)); { //分割窗左边的列表框 selectList = new List(sashForm, SWT.BORDER); //作为演示只加了两项 selectList.setItems(new String[] { "个人资料", "联系方式" }); //加一个鼠标监听器 selectList.addMouseListener(new MyMouseLister());// } { //右边的堆栈式面板 rightComp = new Composite(sashForm, SWT.NONE); rightComp.setLayout(stackLayout); //共两页。将生成此面板的代码提出成一个方法,保证代码结构的清晰。 yourDataComp = createYourDataComp(rightComp);//个人资料的面板 otherComp = createOtherComp(rightComp);//联系方式的面板 //在堆栈面板上先显示“个人资料”界面 stackLayout.topControl = yourDataComp; } //分割窗口的左右空间比例 sashForm.setWeights(new int[] { 1, 4 }); } { //界面的按钮的面板 Composite buttonComp = new Composite(shell, SWT.BORDER); //使用GridData设置buttonComp在它父容器Shell中的布局方式 GridData gridData = new GridData(); gridData.horizontalAlignment = GridData.END;//让buttonComp向右靠 buttonComp.setLayoutData(gridData); //设置buttonComp的布局为RowLayout,用来设定buttonComp内组件的布局方式 RowLayout rowLayout = new RowLayout(); rowLayout.spacing = 15;//按钮之间间隔15个像素 buttonComp.setLayout(rowLayout); //在buttonComp下建立三个按钮 new Button(buttonComp, SWT.NONE).setText(" 确定 "); new Button(buttonComp, SWT.NONE).setText(" 取消 "); new Button(buttonComp, SWT.NONE).setText(" 应用 "); } shell.layout(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } /** 个人资料面板的生成 */ private Composite createYourDataComp(Composite rightComp) { Composite composite = new Composite(rightComp, SWT.NONE); composite.setLayout(new GridLayout(6, false));//个人资料面板分成6列 //---------用户号码的标签及其文本框 new Label(composite, SWT.NONE).setText("用户号码:"); //只读型的文本框 Text text = new Text(composite, SWT.READ_ONLY | SWT.BORDER); //水平抢占式充满,并占用三列的空间. createGridData是自定义方法 text.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 3)); //---------图片部份.我们再用一个面板嵌套来管理 Composite photoComp = new Composite(composite, SWT.BORDER); //水平垂直对齐式充满,横占两列,竖占4行. photoComp.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL, 2, 4)); photoComp.setLayout(new GridLayout(2, false));//分2列 { //图片. Image类的使用暂时还没有讲到,我们先用一个Composite来代替图片. Composite tempComp = new Composite(photoComp, SWT.BORDER); tempComp.setLayoutData(new GridData(50, 50));//设定大小:宽50,高50 //选择图片的箭头型按钮,并设置它向下靠 Button selPhotoButton = new Button(photoComp, SWT.ARROW | SWT.DOWN); selPhotoButton.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_END)); //升级成为会员的按钮.横占photoComp的两列,并横向对齐充满 Button updateButton = new Button(photoComp, SWT.NONE); updateButton.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL, 2)); updateButton.setText("升级成为会员"); } new Label(composite, SWT.NONE).setText("用户呢称:"); Text nicknameText = new Text(composite, SWT.BORDER); nicknameText.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL, 3)); new Label(composite, SWT.NONE).setText("个性签名:"); Text attachNameText = new Text(composite, SWT.BORDER); attachNameText.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL, 3)); new Label(composite, SWT.NONE).setText("等 级:"); { //Image类的使用暂时还没有讲到,我们先用一个Composite来代替图片 Composite tempComp = new Composite(composite, SWT.BORDER); GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); gridData.horizontalSpan = 3; //Composite默认的高度太高,故手工设定高度为20像素 gridData.heightHint = 20; tempComp.setLayoutData(gridData); } new Label(composite, SWT.NONE).setText("性 别:"); Combo sexCombo = new Combo(composite, SWT.NONE); new Label(composite, SWT.NONE).setText("姓名:"); Text nameText = new Text(composite, SWT.BORDER); nameText.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); new Label(composite, SWT.NONE).setText("年龄:"); Text oldText = new Text(composite, SWT.BORDER); oldText.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); new Label(composite, SWT.NONE).setText("毕业院校:"); Text schoolText = new Text(composite, SWT.BORDER); schoolText.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL, 3)); new Label(composite, SWT.NONE).setText("生肖:"); Combo animalCombo = new Combo(composite, SWT.NONE); animalCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); new Label(composite, SWT.NONE).setText("职 业:"); Text jobText = new Text(composite, SWT.BORDER); jobText.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL, 3)); new Label(composite, SWT.NONE).setText("星座:"); Combo constellationCombo = new Combo(composite, SWT.NONE); constellationCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
评论
    相关推荐
    • swt form
      NULL 博文链接:https://dadi520.iteye.com/blog/726637
    • swt form
      NULL 博文链接:https://dadi520.iteye.com/blog/726637
    • swt form
      NULL 博文链接:https://dadi520.iteye.com/blog/726637
    • swt form
      NULL 博文链接:https://dadi520.iteye.com/blog/726637
    • SWT SDK
      swt开发包,swt通过调用本地操作系统资源来生成更快的更好看的GUI
    • swt
      NULL 博文链接:https://zfwdl2005.iteye.com/blog/839857
    • SWT注册
      SWT&Swing.Designer_Window.Builder.Pro_v6_for_Eclipse3.2_Keygen注册文件
    • SWT designer
      SWT designer,用于开发eclipse下开发SWT界面
    • eclipse swt
      包中包括的类有:org.eclipse.swt.SWT.class org.eclipse.swt.SWTError.class org.eclipse.swt.SWTException.class org.eclipse.swt.accessibility.ACC.class org.eclipse.swt.accessibility.Accessible.class org....
    • swtdesigner
      eclipse 插件开发中的swt designer的使用