当前位置: 代码迷 >> Eclipse >> rcp开发,小例子遇到一些线程有关问题-哎真没办法了,求帮忙
  详细解决方案

rcp开发,小例子遇到一些线程有关问题-哎真没办法了,求帮忙

热度:4   发布时间:2016-04-23 00:27:32.0
rcp开发,小例子遇到一些线程问题--哎真没办法了,求帮忙
我是想通过view做出
如下图的效果:


public class Productview extends ViewPart {
  private Label titl;
  private Text name;
  private Combo category;
  private Text cost;
  private Text sellPrice;
  private Text productNum;
  private Text profitRate;
  private Button submit;
  private String nameString;
  private String categorystr;
  private String pronum;
  private double costd;
  private double sellP;
  private double pr;

  @Override
  public void createPartControl(Composite parent) {
    final Display display = Display.getDefault();
    parent.setLayout(null);
    Label label1 = new Label(parent, SWT.NONE);
    label1.setText("名称:");
    label1.setBounds(360, 120, 60, 20);
    Label label2 = new Label(parent, SWT.NONE);
    label2.setText("类型:");
    label2.setBounds(360, 180, 60, 20);
    Label label3 = new Label(parent, SWT.NONE);
    label3.setText("成本:");
    label3.setBounds(360, 240, 60, 20);
    Label label4 = new Label(parent, SWT.NONE);
    label4.setText("编号:");
    label4.setBounds(360, 300, 60, 20);
    Label label5 = new Label(parent, SWT.NONE);
    label5.setText("售价:");
    label5.setBounds(360, 360, 60, 20);
    Label label6 = new Label(parent, SWT.NONE);
    label6.setText("利润率:");
    label6.setBounds(360, 420, 60, 20);
    titl = new Label(parent, SWT.NONE);
    titl.setText("产品统计系统");
    category = new Combo(parent, SWT.NONE);
    category.add("Bangle");
    category.add("Brecelet");
    category.add("Necklace Pendents");
    category.add("Ring");
    category.add("Jewelry Set");
    name = new Text(parent, SWT.NONE | SWT.WRAP);
    cost = new Text(parent, SWT.NONE | SWT.WRAP);
    sellPrice = new Text(parent, SWT.NONE | SWT.WRAP);
    productNum = new Text(parent, SWT.NONE | SWT.WRAP);
    profitRate = new Text(parent, SWT.NONE | SWT.WRAP);
    submit = new Button(parent, SWT.NONE);
    submit.setText("提交");
    submit.setBounds(460, 540, 60, 20);
    name.setBounds(420, 120, 180, 20);
    category.setBounds(420, 180, 180, 20);
    cost.setBounds(420, 240, 180, 20);
    productNum.setBounds(420, 300, 180, 20);
    sellPrice.setBounds(420, 360, 180, 20);
    profitRate.setBounds(420, 420, 180, 20);
    submit.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        Thread thread = new Thread() {
          @Override
          public void run() {
            final Product product = new Product();
            display.asyncExec(new Runnable() {

              @Override
              public void run() {
                nameString = name.getText();
                categorystr = category.getText();
                costd = Double.valueOf(cost.getText());
                pronum = productNum.getText();
                sellP = Double.valueOf(sellPrice.getText());
  相关解决方案