SWT常用组件
发布日期:2021-05-10 11:43:49 浏览次数:12 分类:精选文章

本文共 5894 字,大约阅读时间需要 19 分钟。

SWT������������������

SWT���Standard Widget Toolkit������Eclipse������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������SWT���������������������������������������������������������������������������������������������������������


������������������

1.���������������Button���

���������������������SWT���������������������������������������������������������������������������

���1���������������

Button������������������������������������������������������������������������������|������������������������������������

  • SWT.PUSH���������������
  • SWT.CHECK���������������
  • SWT.RADIO���������������
  • SWT.ARROW���������������������
  • SWT.NONE���������������
  • SWT.LEFT���RIGHT���CENTER���������������������
  • SWT.BORDER������������������
  • SWT.FLAT������������������

���������

Button bt = new Button(shell, SWT.CHECK | SWT.BORDER | SWT.LEFT);

���2���������������

  • ���������������setText(String string)
  • ���������������setBounds(int x, int y, int width, int height)
  • ������/���������setEnabled(Boolean enabled)
  • ���������������setFont(Font font)
  • ���������������setForeground(Color color) ��� setBackground(Color color)
  • ���������������setImage(Image image)
  • ���������������setSelection(Boolean selected)
  • ���������������setToolTipText(String string)

2.���������������Label���

���������������������������������������������������������������������������������������

���1���������

���������������������

  • SWT.CENTER���������
  • SWT.RIGHT������������
  • SWT.LEFT������������
  • SWT.NONE���������
  • SWT.WRAP���������������
  • SWT.BORDER������������
  • SWT.SEPARATOR���������������������������������������
  • SWT.HORIZONTAL������������������

���������

Label label = new Label(shell, SWT.CENTER);

3.������������������Text���

������������������������������������������������������������������������

���1���������

���������������

  • SWT.NONE���������
  • SWT.MULTI���������������������
  • SWT.WRAP���������������
  • SWT.PASSWORD������������������������������
  • SWT.BORDER������������
  • SWT.V_SCROLL������������������
  • SWT.H_SCROLL������������������

���2���������������

  • ���������������getText() ��� getCurrentText()
  • ���������������������setText(String string)
  • ���������������������setMinimumWidth(int min) ��� setMaximumWidth(int max)
  • ������������������������setVerticalScrollBarPolicy(int policy) ��� setHorizontalScrollBarPolicy(int policy)

4.������������������Combo���

���������������������������������������������������

���1���������

���������������

  • SWT.NONE���������
  • SWT.READ_ONLY���������������

���2���������������

  • ������������add(String string) ��� add(String string, int index)
  • ������������insert(String string, int index)
  • ������������removeAll()
  • ������������setItems(String[] items)
  • ������������select(int index)

5.������������������List���

������������������������������������������������������������������

���1���������

  • SWT.NONE���������
  • SWT.MULTI���������
  • SWT.SINGLE���������

���2���������

  • ������������add(String string) ��� add(String[] strings)
  • ������������insert(String string, int index)
  • ������������select(int index)
  • ���������������������getSelection() ������String������

���������������

1.���������Composite���

������������������������������������������������������������������������������������������������������������������������������������������

���1���������������

  • ������������������������getLayout()
  • ���������������������getLayoutData()
  • ������������������getParent()
  • ���������������layout()

2.������������Group���

���������������Composite������������������������������������������������������������������������������������������

���2���������������

Group group = new Group(shell);
group.setText("���������������");

3.������������TabFolder���TabItem���

������������������������������������������

���1���TabFolder

  • ������������������������new TabFolder(shell)
  • ������������������add(TabItem tabItem)
  • ������������������setSelectedTab(TabItem tabItem)

���2���TabItem

  • ���������������������new TabItem(tabFolder, composite)
  • ���������������������setControl(Control control)

���������������������

1.������������������FillLayout���

���������������������������������������������������

���1���������������

  • FillLayout()
  • FillLayout(int type)���type ��� SWT.HORIZONTAL������������ SWT.VERTICAL���������

���2���������

  • type���������������

2.���������������RowLayout���

������������������������������������������������

���1���������������

  • RowLayout()
  • RowLayout(int type)

���2���������

  • marginWidth���������������������������������������
  • marginHeight���������������������������������������
  • marginTop���marginBottom���������������������
  • spacing���������������
  • justify���������������������������������
  • wrap���������������������
  • type������������������

3.������������������GridLayout���

GridLayout���������������������������������������������������������������

���1���������������

GridLayout gl = new GridLayout();
gl.setType(SWT.HORIZONTAL); // ���������

���2���������

  • numColumn���������
  • makeColumnsEqualWidth���������������������
  • marginWidth���marginHeight���������������
  • horizontalSpacing������������
  • verticalSpacing������������

4.������������������FormLayout���

������������������������������������������������������FormData���������������������

���1���������������

FormLayout layout = new FormLayout();

���2���FormData

FormData������������������������������������������������������������

���3���FormAttachment

FormAttachment������������������������������������������������������������������������������


������SWT���������������

��������������������������������� org.eclipse.swt.events ���������

������������������

  • MouseListener���������������
    • mouseDown()
    • mouseUp()
    • mouseDoubleClick()
  • KeyListener���������������
    • keyPressed()
    • keyReleased()
  • SelectionListener���������������������
    • widgetSelected()
  • FocusListener���������������
    • focusGained()
    • focusLost()

���������������������������������������������SWT���������������������������

上一篇:java.lang.RuntimeException: wrong class format
下一篇:J2EE学习笔记(五)之Servlet中的Filter过滤器

发表评论

最新留言

做的很好,不错不错
[***.243.131.199]2025年04月24日 22时29分04秒