本文整理汇总了Java中org.eclipse.swt.widgets.Spinner类的典型用法代码示例。如果您正苦于以下问题:Java Spinner类的具体用法?Java Spinner怎么用?Java Spinner使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Spinner类属于org.eclipse.swt.widgets包,在下文中一共展示了Spinner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDialogArea
import org.eclipse.swt.widgets.Spinner; //导入依赖的package包/类
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
Label labelDescription = new Label(composite, SWT.WRAP);
labelDescription.setText("Limit chars logs");
final Spinner spinnerBox = new Spinner(composite, SWT.WRAP);
spinnerBox.setMaximum(MAX_LOG_CHARS);
spinnerBox.setMinimum(MIN_LOG_CHARS);
spinnerBox.setSelection(limitLogsChars);
spinnerBox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
spinnerBox.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
limitLogsChars = Integer.parseInt(spinnerBox.getText());
}
});
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
composite.setLayout(new GridLayout(2, false));
return composite;
}
示例2: createWidgets
import org.eclipse.swt.widgets.Spinner; //导入依赖的package包/类
@Override
protected void createWidgets(String text, String toolTip, Integer initialValue) {
lbl = new Label(this, SWT.NONE);
lbl.setText(text);
spinner = new Spinner(this, SWT.CHECK);
spinner.setToolTipText(toolTip);
spinner.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
Integer value = spinner.getSelection();
if (value != getValue()) {
setValue(value, false);
}
}
});
}
示例3: createWidgets
import org.eclipse.swt.widgets.Spinner; //导入依赖的package包/类
@Override
protected void createWidgets(String text, String toolTip, Double initialValue) {
lbl = new Label(this, SWT.NONE);
lbl.setText(text);
spinner = new Spinner(this, SWT.CHECK);
spinner.setToolTipText(toolTip);
spinner.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
double value = spinner.getSelection() / scale;
if (value != getValue()) {
setValue(value, false);
}
}
});
}
示例4: getWidget
import org.eclipse.swt.widgets.Spinner; //导入依赖的package包/类
/**
* Retrieves the control from the viewer
*/
public static Control getWidget(Object control) {
if (control instanceof Viewer) {
return ((Viewer) control).getControl();
} else if (control instanceof Text) {
return (Text) control;
} else if (control instanceof Button) {
return (Control) control;
} else if (control instanceof Spinner) {
return (Control) control;
} else if (control instanceof Control) {
// why not return the control when object is instanceof control?
return null;
}
return null;
}
示例5: setSelectedColor
import org.eclipse.swt.widgets.Spinner; //导入依赖的package包/类
private void setSelectedColor(Control control, boolean selection) {
if (selection) {
control.setForeground(control.getParent().getForeground());
if (!((control instanceof Text) || (control instanceof Combo)
|| (control instanceof MultiChoice<?>) || (control instanceof Spinner))) {
control.setBackground(BACKGROUND_COLOR);
}
} else {
control.setForeground(BTSUIConstants.VIEW_FOREGROUND_DESELECTED_COLOR);
control.setBackground(BTSUIConstants.VIEW_BACKGROUND_DESELECTED_COLOR);
}
if (control instanceof Composite) {
for (Control child : ((Composite) control).getChildren()) {
setSelectedColor(child, selection);
}
}
}
示例6: LinesPerPageDialog
import org.eclipse.swt.widgets.Spinner; //导入依赖的package包/类
private LinesPerPageDialog(Shell parentShell)
{
shell = new Shell(parentShell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
shell.setText("Lines per Page");
shell.setLayout(new GridLayout(3, true));
spinner = new Spinner(shell, 0);
spinner.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
spinner.setValues(bzStyledText.getLinesPerPage(), 0, 225, 0, 1, 10);
spinner.addKeyListener(this);
okButton = new Button(shell, SWT.PUSH);
okButton.setText("OK");
okButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
okButton.addSelectionListener(this);
cancelButton = new Button(shell, SWT.PUSH);
cancelButton.setText("Cancel");
cancelButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
cancelButton.addSelectionListener(this);
shell.pack();
shell.open();
}
示例7: CharsPerLineDialog
import org.eclipse.swt.widgets.Spinner; //导入依赖的package包/类
private CharsPerLineDialog(Shell parentShell)
{
shell = new Shell(parentShell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
shell.setText("Characters Per Line");
shell.setLayout(new GridLayout(3, true));
spinner = new Spinner(shell, 0);
spinner.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
spinner.setValues(bzStyledText.getCharsPerLine(), 0, 27720, 0, 1, 10);
spinner.addKeyListener(this);
okButton = new Button(shell, SWT.PUSH);
okButton.setText("OK");
okButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
okButton.addSelectionListener(this);
cancelButton = new Button(shell, SWT.PUSH);
cancelButton.setText("Cancel");
cancelButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
cancelButton.addSelectionListener(this);
shell.pack();
shell.open();
}
示例8: LineMarginBellDialog
import org.eclipse.swt.widgets.Spinner; //导入依赖的package包/类
private LineMarginBellDialog(Shell parentShell)
{
shell = new Shell(parentShell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
shell.setText("Bell Margin");
shell.setLayout(new GridLayout(3, true));
spinner = new Spinner(shell, 0);
spinner.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
spinner.setValues(bzStyledText.getLineMarginBell(), 0, 27720, 0, 1, 10);
spinner.addKeyListener(this);
okButton = new Button(shell, SWT.PUSH);
okButton.setText("OK");
okButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
okButton.addSelectionListener(this);
cancelButton = new Button(shell, SWT.PUSH);
cancelButton.setText("Cancel");
cancelButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
cancelButton.addSelectionListener(this);
shell.pack();
shell.open();
}
示例9: PageMarginBellDialog
import org.eclipse.swt.widgets.Spinner; //导入依赖的package包/类
private PageMarginBellDialog(Shell parentShell)
{
shell = new Shell(parentShell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
shell.setText("Bell Page");
shell.setLayout(new GridLayout(3, true));
spinner = new Spinner(shell, 0);
spinner.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
spinner.setValues(bzStyledText.getPageMarginBell(), 0, 27720, 0, 1, 10);
spinner.addKeyListener(this);
okButton = new Button(shell, SWT.PUSH);
okButton.setText("OK");
okButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
okButton.addSelectionListener(this);
cancelButton = new Button(shell, SWT.PUSH);
cancelButton.setText("Cancel");
cancelButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
cancelButton.addSelectionListener(this);
shell.pack();
shell.open();
}
示例10: storeOptionValues
import org.eclipse.swt.widgets.Spinner; //导入依赖的package包/类
public void storeOptionValues() {
IPreferenceStore store = getPreferenceStore();
controlMap.forEach((serviceId, optionControlPairs) -> {
optionControlPairs.forEach(optionControlPair -> {
Option<?> option = optionControlPair.getLeft();
Control control = optionControlPair.getRight();
String storeKey = Activator.getStoreKey(serviceId, option);
option.matchVoid(booleanOption -> {
store.setValue(storeKey, ((Button) control).getSelection());
}, numberOption -> {
store.setValue(storeKey, ((Spinner) control).getSelection());
}, textOption -> {
store.setValue(storeKey, ((Text) control).getText());
}, xorOption -> {
store.setValue(storeKey, ((Combo) control).getSelectionIndex());
}, optionGroup -> {
});
});
});
}
示例11: RangeTool
import org.eclipse.swt.widgets.Spinner; //导入依赖的package包/类
/**
* Construct the {@code RangeTool} UI with the given set of options.
*
* @param parent containing window for range tool
* @param style basic presentation options
*/
public RangeTool(Composite parent, int style,
String label, RelationCount.RangeData setup) {
super(parent, style);
setLayout(new RowLayout());
Label rangeLabel = new Label(this, SWT.LEFT);
rangeLabel.setText(label);
rangeOp = createRangeOp(setup.option);
loLabel = new Label(this, SWT.LEFT);
loLimit = new Spinner(this, style);
hiLabel = new Label(this, SWT.LEFT);
hiLimit = new Spinner(this, style);
setLimits(setup);
}
示例12: handleDirectionChange
import org.eclipse.swt.widgets.Spinner; //导入依赖的package包/类
private void handleDirectionChange(Spinner input) {
// Ignore bad input
float value;
try {
String text = input.getText();
value = Float.parseFloat(text);
} catch (NumberFormatException e) {
return;
}
if (xdirInput.isControl(input)) {
fireXChanged(value);
} else if (ydirInput.isControl(input)) {
fireYChanged(value);
} else if (zdirInput.isControl(input)) {
fireZChanged(value);
}
}
示例13: handlePositionChange
import org.eclipse.swt.widgets.Spinner; //导入依赖的package包/类
private void handlePositionChange(Spinner input) {
// Ignore bad input
float value;
try {
String text = input.getText();
value = Float.parseFloat(text);
} catch (NumberFormatException e) {
return;
}
if (xposInput.isControl(input)) {
fireXChanged(value);
} else if (yposInput.isControl(input)) {
fireYChanged(value);
} else if (zposInput.isControl(input)) {
fireZChanged(value);
}
}
示例14: refresh
import org.eclipse.swt.widgets.Spinner; //导入依赖的package包/类
@Override
public void refresh() {
final String value = getSimpleValueOrDefault();
if (StringUtils.isNotEmpty(value)) {
for (final Control childControl : periodControl.getChildren()) {
if (childControl instanceof Spinner) {
Spinner actualControl = (Spinner) childControl;
String periodKey = (String) childControl.getData("PERIOD_KEY");
PeriodPropertyElement element = PeriodPropertyElement.byShortFormat(periodKey);
if (element != null) {
actualControl.setSelection(ExtensionPropertyUtil.getPeriodPropertyElementFromValue(value, element));
}
}
}
}
}
示例15: createRadio
import org.eclipse.swt.widgets.Spinner; //导入依赖的package包/类
/**
* Create a radio button followed by a spinner with a maximum and a minimum value. At the radio
* button can be associated a governor. This object define how the color picker area is painted.
* This is done because when a button is selected its governor is set into the color picker widget
* changing the color space. When a radio button created with this method is selected all the other
* are deselected.
*
* @param parent parent of the controls
* @param title content of a label placed as text of the radio button
* @param suffix content of a label placed after the spinner
* @param governor the governor that is loaded in the color picker widget when the button is selected
* @param defaultEnabled true if the radio button is enabled by default, false otherwise
* @param min min int value for the spinner
* @param max max int value for the spinner
* @return the spinner created
*/
private Spinner createRadio(Composite parent, String title, String suffix, IWidgetGovernor governor, boolean defaultEnabled, int min, int max){
final Button radio = new Button(parent, SWT.RADIO);
radioList.add(radio);
radio.setText(title);
radio.setData(governor);
radio.setSelection(defaultEnabled);
radio.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (radio.getSelection()){
disableAllRadioExceptOne(radio);
colorsSelector.setGovernor((IWidgetGovernor)radio.getData());
}
}
});
Spinner actualText = new Spinner(parent, SWT.BORDER);
actualText.setMinimum(min);
actualText.setMaximum(max);
actualText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
if (suffix != null) new Label(parent, SWT.NONE).setText(suffix);
else new Label(parent, SWT.NONE);
actualText.addModifyListener(valueModifedListener);
return actualText;
}