本文整理汇总了Java中org.eclipse.swt.widgets.CoolItem.setPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:Java CoolItem.setPreferredSize方法的具体用法?Java CoolItem.setPreferredSize怎么用?Java CoolItem.setPreferredSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.widgets.CoolItem
的用法示例。
在下文中一共展示了CoolItem.setPreferredSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createToolBar
import org.eclipse.swt.widgets.CoolItem; //导入方法依赖的package包/类
/**
*
*/
protected void createToolBar() {
CoolBar bar = new CoolBar(shell, SWT.FLAT);
bar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
bar.setLayout(new RowLayout());
CoolItem item = new CoolItem(bar, SWT.NONE);
Button button = new Button(bar, SWT.FLAT);
// button.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true));
button.setText("Button");
Point size = button.computeSize(SWT.DEFAULT, SWT.DEFAULT);
item.setPreferredSize(item.computeSize(size.x, size.y));
item.setControl(button);
Rectangle clientArea = shell.getClientArea();
bar.setLocation(clientArea.x, clientArea.y);
bar.pack();
}
示例2: createCoolItem
import org.eclipse.swt.widgets.CoolItem; //导入方法依赖的package包/类
private void createCoolItem(final CoolBar coolBar, final ToolBar toolBar) {
Check.notNull(coolBar, "coolBar"); //$NON-NLS-1$
Check.notNull(toolBar, "toolBar"); //$NON-NLS-1$
// Compute the size of the toolbar
toolBar.pack();
final Point toolBarSize = toolBar.getSize();
// Create a CoolItem to hold the toolbar
final CoolItem coolItem = new CoolItem(coolBar, SWT.NONE);
coolItem.setControl(toolBar);
// Set the preferred size to what was computed from the toolbar
final Point coolItemSize = coolItem.computeSize(toolBarSize.x, toolBarSize.y);
/*
* SWT Quirk (Bug?)
*
* The cool item should have its PREFERRED size set to the result of its
* OWN computeSize() calculation, but its MINIMUM size should be set to
* its "child" TOOL BAR's computed size. I think it should rightly use
* the same size (its OWN computed size) for minimum size, but this
* leaves way too much empty space in the right side of the toolbar.
*/
coolItem.setPreferredSize(coolItemSize);
coolItem.setMinimumSize(toolBarSize);
}
示例3: adjustCoolbar
import org.eclipse.swt.widgets.CoolItem; //导入方法依赖的package包/类
public static void adjustCoolbar(ChessBoard board, ToolBar toolbar) {
clearCoolbar(board);
toolbar.pack();
Point size = toolbar.getSize();
board.getCoolbar().setVisible(true);
board.getCoolbar().setLocked(true);
CoolItem coolItem = new CoolItem(board.getCoolbar(), SWT.NONE);
coolItem.setControl(toolbar);
coolItem.setSize(size.x, size.y);
coolItem.setPreferredSize(size.x, size.y);
coolItem.setMinimumSize(size);
board.getControl().layout();
}
示例4: makeCoolItem
import org.eclipse.swt.widgets.CoolItem; //导入方法依赖的package包/类
private void makeCoolItem(ToolBar toolBar){
Point size = toolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT);
CoolItem coolItem = new CoolItem(this.coolBar, SWT.NONE);
coolItem.setMinimumSize(size);
coolItem.setPreferredSize(coolItem.computeSize(size.x, size.y));
coolItem.setControl(toolBar);
}
示例5: construct
import org.eclipse.swt.widgets.CoolItem; //导入方法依赖的package包/类
public Control construct(Composite parent) {
final Composite composite = new Composite(parent, SWT.NONE);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL)
.grab(true, true).applyTo(composite);
GridLayoutFactory.swtDefaults().numColumns(2).applyTo(composite);
final Text t = new Text(composite, SWT.BORDER | SWT.MULTI);
t.setText ("Test at the pressing");
CoolBar bar = new CoolBar(composite, SWT.VERTICAL);
for (int i=1; i<6; i++) {
CoolItem item = new CoolItem (bar, SWT.NONE);
final Button button = new Button (bar, SWT.PUSH);
button.setText ("Button " + i);
Point size = button.computeSize (SWT.DEFAULT, SWT.DEFAULT);
item.setPreferredSize (item.computeSize (size.x, size.y));
item.setControl (button);
final String t2 = button.getText();
button.addListener (SWT.Selection, new Listener () {
public void handleEvent (Event e) {
t.setText(t2);
}
});
}
Rectangle clientArea = composite.getClientArea ();
bar.setLocation (clientArea.x, clientArea.y);
return null;
}