• JTable


    final Table table = new Table(parent, SWT.NONE | SWT.FULL_SELECTION);
      final GridData gd = new GridData(SWT.LEFT, SWT.TOP, false, true);
      gd.heightHint = 100;
      table.setLayoutData(gd);
      table.setHeaderVisible(true);
      table.setLinesVisible(true);
      final TableColumn tcCondition = new TableColumn(table, SWT.None);
      final TableColumn tcUserValue = new TableColumn(table, SWT.None);
      final TableColumn tcUserColor = new TableColumn(table, SWT.None);
      tcCondition.setText("条件");
      tcCondition.setWidth(80);
      tcUserValue.setText("枚举值");
      tcUserValue.setWidth(80);
      tcUserColor.setText("颜色");
      tcUserColor.setWidth(80);
      table.addListener(SWT.MouseDoubleClick, new Listener() {
       int editColumnIndex = -1;
       @Override
       public void handleEvent(final Event e) {
        final Point point = new Point(e.x, e.y);
        final TableItem tableItem = table.getItem(point);
        if (tableItem == null) {
         return;
        }
        for (int i = 0; i < 3; i++) {
         final Rectangle r = tableItem.getBounds(i);
         if (r.contains(point)) {
          editColumnIndex = i;
          final TableEditor editor = new TableEditor(table);
          final Control oldEditor = editor.getEditor();
          if (oldEditor != null) {
           oldEditor.dispose();
          }
          final Text text = new Text(table, SWT.NONE);
          text.computeSize(SWT.DEFAULT, table.getItemHeight());
          editor.grabHorizontal = true;
          editor.minimumHeight = text.getSize().y;
          editor.minimumWidth = text.getSize().x;
          editor.setEditor(text, tableItem, editColumnIndex);
          text.setText(tableItem.getText(editColumnIndex));
          text.forceFocus();
          text.addModifyListener(new ModifyListener() {
           @Override
           public void modifyText(final ModifyEvent e) {
            editor.getItem().setText(editColumnIndex, text.getText());
           }
          });
          text.addFocusListener(new FocusListener() {
           @Override
           public void focusGained(final FocusEvent e) {
            // TODO Auto-generated method stub
           }
           @Override
           public void focusLost(final FocusEvent e) {
            text.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));
            text.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));
           }
          });
         }
        }
       }
      });
    

      

  • 相关阅读:
    47.一个h5画板
    46.纯css实现瀑布流(flex)
    45.使用webpack,react,redux搭俩个界面
    44.一个这样的datePicker
    43.关于浮点数的乘除法预算误差,一个看似没什么问题的解决方法
    iOS10 NSBundle
    iOS09-NSUserDefault
    iOS08 页面跳转动画设置方法
    iOS07 键盘弹出,回收,位置
    iOS06 NSTimer 详细设置1
  • 原文地址:https://www.cnblogs.com/nicebaby/p/6273047.html
Copyright © 2020-2023  润新知