org.eclipse.swt.widgets.Text.setSize()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(191)

本文整理了Java中org.eclipse.swt.widgets.Text.setSize()方法的一些代码示例,展示了Text.setSize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Text.setSize()方法的具体详情如下:
包路径:org.eclipse.swt.widgets.Text
类名称:Text
方法名:setSize

Text.setSize介绍

暂无

代码示例

代码示例来源:origin: openaudible/openaudible

public static Text newShortTextInput(Composite parent, String title, int textLimit, int width) {
  Text t = newInput(parent, title, SWT.BORDER);
  
  t.setTextLimit(textLimit);
  Rectangle r = t.getBounds();
  r.width = width;
  t.setBounds(r);
  t.setSize(width, r.height);
  t.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
  return t;
}

代码示例来源:origin: openaudible/openaudible

public Text newShortTextInput(int textLimit, int width) {
  Text t = newInput(this, null, SWT.BORDER);
  t.setTextLimit(textLimit);
  Rectangle r = t.getBounds();
  r.width = width;
  t.setBounds(r);
  t.setSize(width, r.height);
  t.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
  return t;
}

代码示例来源:origin: xzer/run-jetty-run

private void setWidthForSampleText(Text control, String sampleText) {
  GC gc = new GC(control);
  try {
    Point sampleSize = gc.textExtent(sampleText);
    Point currentSize = control.getSize();
    sampleSize.y = currentSize.y;
    control.setSize(sampleSize);
    return;
  } finally {
    gc.dispose();
  }
}

代码示例来源:origin: com.github.rinde/rinsim-example

@Override
public void initializePanel(Composite parent) {
 final FillLayout rl = new FillLayout();
 parent.setLayout(rl);
 final Text t = new Text(parent, SWT.SINGLE | SWT.ICON_CANCEL | SWT.CANCEL);
 t.setText(startString);
 final GC gc = new GC(t);
 final FontMetrics fm = gc.getFontMetrics();
 final int width = CHARS * fm.getAverageCharWidth();
 final int height = fm.getHeight();
 gc.dispose();
 t.setSize(t.computeSize(width, height));
 t.addListener(SWT.DefaultSelection, this);
 t.addListener(SWT.Modify, this);
 vehicles.addAll(roadModel.getObjectsOfType(Vehicle.class));
}

代码示例来源:origin: rinde/RinSim

@Override
public void initializePanel(Composite parent) {
 final FillLayout rl = new FillLayout();
 parent.setLayout(rl);
 final Text t = new Text(parent, SWT.SINGLE | SWT.ICON_CANCEL | SWT.CANCEL);
 t.setText(startString);
 final GC gc = new GC(t);
 final FontMetrics fm = gc.getFontMetrics();
 final int width = CHARS * fm.getAverageCharWidth();
 final int height = fm.getHeight();
 gc.dispose();
 t.setSize(t.computeSize(width, height));
 t.addListener(SWT.DefaultSelection, this);
 t.addListener(SWT.Modify, this);
 vehicles.addAll(roadModel.getObjectsOfType(Vehicle.class));
}

代码示例来源:origin: stackoverflow.com

text.setSize(200, 20);
shell.pack();
shell.open();

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench

private void updateQuickAccessText() {
  if (txtQuickAccess == null || txtQuickAccess.isDisposed()) {
    return;
  }
  updateQuickAccessTriggerSequence();
  if (triggerSequence != null) {
    txtQuickAccess.setToolTipText(
        NLS.bind(QuickAccessMessages.QuickAccess_TooltipDescription, triggerSequence.format()));
  } else {
    txtQuickAccess.setToolTipText(QuickAccessMessages.QuickAccess_TooltipDescription_Empty);
  }
  GC gc = new GC(txtQuickAccess);
  // workaround for Bug 491317
  if (Util.isWin32() || Util.isGtk()) {
    FontMetrics fm = gc.getFontMetrics();
    int wHint = QuickAccessMessages.QuickAccess_EnterSearch.length() * fm.getAverageCharWidth();
    int hHint = fm.getHeight();
    gc.dispose();
    txtQuickAccess.setSize(txtQuickAccess.computeSize(wHint, hHint));
  } else {
    Point p = gc.textExtent(QuickAccessMessages.QuickAccess_EnterSearch);
    Rectangle r = txtQuickAccess.computeTrim(0, 0, p.x, p.y);
    gc.dispose();
    // computeTrim() may result in r.x < 0
    GridDataFactory.fillDefaults().hint(r.width - r.x, SWT.DEFAULT).applyTo(txtQuickAccess);
  }
  txtQuickAccess.requestLayout();
}

相关文章

Text类方法