本文整理了Java中org.eclipse.swt.widgets.Button
类的一些代码示例,展示了Button
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button
类的具体详情如下:
包路径:org.eclipse.swt.widgets.Button
类名称:Button
[英]Instances of this class represent a selectable user interface object that issues notification when pressed and released. Styles: ARROW, CHECK, PUSH, RADIO, TOGGLE, FLAT, WRAP UP, DOWN, LEFT, RIGHT, CENTER Events: Selection
Note: Only one of the styles ARROW, CHECK, PUSH, RADIO, and TOGGLE may be specified.
Note: Only one of the styles LEFT, RIGHT, and CENTER may be specified.
Note: Only one of the styles UP, DOWN, LEFT, and RIGHT may be specified when the ARROW style is specified.
IMPORTANT: This class is not intended to be subclassed.
[中]此类的实例表示一个可选择的用户界面对象,在按下和释放时发出通知。样式:箭头、勾选、推送、单选、切换、展开、上折、下折、左折、右折、居中事件:选择
注意:只能指定箭头、复选框、按钮、收音机和切换中的一种样式。
注意:只能指定左、右和中的一种样式。
注意:指定箭头样式时,只能指定上、下、左和右样式之一。
重要提示:该类不打算被子类化。
代码示例来源:origin: pentaho/pentaho-kettle
/**
* build Ok Button.
*/
protected void buildOkButton() {
Button ok = new Button( this.dialog, SWT.PUSH );
ok.setText( BaseMessages.getString( PKG, "TeraFastDialog.About.Plugin.Close" ) );
GridData grdData = new GridData( GridData.HORIZONTAL_ALIGN_CENTER );
grdData.horizontalSpan = 2;
grdData.verticalIndent = DEFAULT_INDENT;
grdData.horizontalIndent = DEFAULT_INDENT;
ok.setLayoutData( grdData );
ok.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event arg0 ) {
dialog.dispose();
}
} );
}
代码示例来源:origin: pentaho/pentaho-kettle
protected Button addStandardCheckBox( String labelMessageKey, Control prevControl ) {
addStandardLabel( labelMessageKey, prevControl );
Button targetControl = new Button( shell, SWT.CHECK );
targetControl.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent e ) {
input.setChanged();
}
} );
targetControl.setLayoutData( standardInputSpacing( prevControl ) );
return targetControl;
}
代码示例来源:origin: pentaho/pentaho-kettle
private void setAddDateBeforeExtension() {
wlAddDateBeforeExtension.setEnabled( wAddDate.getSelection()
|| wAddTime.getSelection() || wSpecifyFormat.getSelection() );
wAddDateBeforeExtension.setEnabled( wAddDate.getSelection()
|| wAddTime.getSelection() || wSpecifyFormat.getSelection() );
if ( !wAddDate.getSelection() && !wAddTime.getSelection() && !wSpecifyFormat.getSelection() ) {
wAddDateBeforeExtension.setSelection( false );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
/**
* @param style
* style to use.
* @param text
* text to set.
* @return new button.
*/
public Button createButton( final int style, final String text ) {
final Button button = new Button( this.shell, style );
button.setText( text );
return button;
}
代码示例来源:origin: pentaho/pentaho-kettle
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
wDesc.setLayoutData( fdDesc );
wOK = new Button( shell, SWT.PUSH );
wOK.setText( BaseMessages.getString( PKG, "System.Button.OK" ) );
wCancel = new Button( shell, SWT.PUSH );
wCancel.setText( BaseMessages.getString( PKG, "System.Button.Cancel" ) );
wOK.setLayoutData( fdOK );
wCancel.setLayoutData( fdCancel );
wOK.addListener( SWT.Selection, lsOK );
wCancel.addListener( SWT.Selection, lsCancel );
} else {
wOK = new Button( shell, SWT.PUSH );
wOK.setText( BaseMessages.getString( PKG, "System.Button.Close" ) );
wOK.setLayoutData( fdOK );
wOK.addListener( SWT.Selection, lsOK );
if ( !display.readAndDispatch() ) {
display.sleep();
代码示例来源:origin: pentaho/pentaho-kettle
btnNext = new Button( sShell, SWT.PUSH );
btnNext.setText( BaseMessages.getString( PKG, "Widget.Styled.Comp.FindNext" ) );
btnNext.setEnabled( false );
btnNext.setLayoutData( frmData );
btnCancel = new Button( sShell, SWT.PUSH );
btnCancel.setText( BaseMessages.getString( PKG, "Widget.Styled.Comp.Close" ) );
btnCancel.setLayoutData( frmData );
btnIgnoreCase = new Button( sShell, SWT.CHECK );
btnIgnoreCase.setText( BaseMessages.getString( PKG, "Widget.Styled.Comp.CaseSensitive" ) );
btnIgnoreCase.setLayoutData( frmData );
btnWrapSearch = new Button( sShell, SWT.CHECK );
btnWrapSearch.setText( BaseMessages.getString( PKG, "Widget.Styled.Comp.WrapSearch" ) );
btnWrapSearch.setLayoutData( frmData );
optForward = new Button( grpDir, SWT.RADIO );
optForward.setText( BaseMessages.getString( PKG, "Widget.Styled.Comp.Forward" ) );
optForward.setBounds( 5, 15, 75, 15 );
Button optBackward = new Button( grpDir, SWT.RADIO );
optBackward.setBounds( 5, 33, 75, 15 );
optForward.setSelection( true );
optBackward.setText( BaseMessages.getString( PKG, "Widget.Styled.Comp.Backward" ) );
代码示例来源:origin: pentaho/pentaho-kettle
shell = new Shell( parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX );
props.setLook( shell );
formLayout.marginHeight = 15;
shell.setLayout( formLayout );
Image image = display.getSystemImage( SWT.ICON_WARNING );
wcMessage.setLayout( new GridLayout() );
wcMessage.setLayoutData( fdcMessage );
Button wbNo = new Button( shell, SWT.PUSH );
wbNo.setText( BaseMessages.getString( PKG, "System.Button.No" ) );
wbNo.addSelectionListener( new SelectionAdapter() {
@Override public void widgetSelected( SelectionEvent selectionEvent ) {
quit( SWT.NO );
wbNo.setLayoutData( fdlNo );
Button wbYes = new Button( shell, SWT.PUSH );
wbYes.setText( BaseMessages.getString( PKG, "RunConfigurationDeleteDialog.Label.Yes" ) );
wbYes.addSelectionListener( new SelectionAdapter() {
@Override public void widgetSelected( SelectionEvent selectionEvent ) {
quit( SWT.YES );
wbYes.setLayoutData( fdlYes );
代码示例来源:origin: pentaho/pentaho-kettle
public void widgetSelected( SelectionEvent e ) {
final Shell dialog = new Shell( shell, SWT.DIALOG_TRIM );
dialog.setText( BaseMessages.getString( PKG, "JobGetPOP.SelectDate" ) );
dialog.setImage( GUIResource.getInstance().getImageSpoon() );
dialog.setLayout( new GridLayout( 3, false ) );
final DateTime calendar = new DateTime( dialog, SWT.CALENDAR );
final DateTime time = new DateTime( dialog, SWT.TIME | SWT.TIME );
new Label( dialog, SWT.NONE );
new Label( dialog, SWT.NONE );
Button ok = new Button( dialog, SWT.PUSH );
ok.setText( BaseMessages.getString( PKG, "System.Button.OK" ) );
ok.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, false, false ) );
ok.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent e ) {
Calendar cal = Calendar.getInstance();
cal.set( Calendar.YEAR, calendar.getYear() );
cal.set( Calendar.MONTH, calendar.getMonth() );
cal.set( Calendar.DAY_OF_MONTH, calendar.getDay() );
cal.set( Calendar.HOUR_OF_DAY, time.getHours() );
cal.set( Calendar.MINUTE, time.getMinutes() );
cal.set( Calendar.SECOND, time.getSeconds() );
wReadFrom.setText( new SimpleDateFormat( JobEntryGetPOP.DATE_PATTERN ).format( cal.getTime() ) );
dialog.close();
}
} );
dialog.setDefaultButton( ok );
dialog.pack();
dialog.open();
}
} );
代码示例来源:origin: pentaho/pentaho-kettle
wStep = new Button( shell, SWT.CHECK );
props.setLook( wStep );
wStep.setToolTipText( BaseMessages.getString( PKG, "EnterSearchDialog.Step.Tooltip" ) );
wStep.setLayoutData( fdStep );
wDB = new Button( shell, SWT.CHECK );
props.setLook( wDB );
wDB.setToolTipText( BaseMessages.getString( PKG, "EnterSearchDialog.DB.Tooltip" ) );
wDB.setLayoutData( fdDB );
wNote = new Button( shell, SWT.CHECK );
props.setLook( wNote );
wNote.setToolTipText( BaseMessages.getString( PKG, "EnterSearchDialog.Note.Tooltip" ) );
wNote.setLayoutData( fdNote );
Button wOK = new Button( shell, SWT.PUSH );
wOK.setText( BaseMessages.getString( PKG, "System.Button.OK" ) );
wOK.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent e ) {
ok();
Button wCancel = new Button( shell, SWT.PUSH );
wCancel.setText( BaseMessages.getString( PKG, "System.Button.Cancel" ) );
wCancel.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent e ) {
cancel();
代码示例来源:origin: pentaho/pentaho-kettle
public void open() {
display = parent.getDisplay();
shell = new Shell( parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN );
props.setLook( shell );
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setText( BaseMessages.getString( PKG, "RepositoryImportDialog.Title" ) );
shell.setImage( GUIResource.getInstance().getImageSpoon() );
shell.setLayout( formLayout );
wLabel = new Label( shell, SWT.LEFT );
props.setLook( wLabel );
wClose = new Button( shell, SWT.PUSH );
wClose.setText( BaseMessages.getString( PKG, "System.Button.Close" ) );
wClose.setEnabled( false );
wClose.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent e ) {
dispose();
wLogging = new Text( shell, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL );
props.setLook( wLabel );
display.asyncExec( new Runnable() {
public void run() {
代码示例来源:origin: pentaho/pentaho-kettle
Button okButton = new Button( shell, SWT.NONE );
okButton.setText( "OK" );
FormData fd_okButton = new FormData();
if ( Const.isOSX() ) {
okButton.setLayoutData( fd_okButton );
okButton.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent e ) {
ok();
Button cancelButton = new Button( shell, SWT.NONE );
cancelButton.setText( "Cancel" );
cancelButton.setLayoutData( fd_cancelButton );
cancelButton.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent e ) {
dispose();
Button btnHelp = new Button( shell, SWT.NONE );
btnHelp.setImage( GUIResource.getInstance().getImageHelpWeb() );
btnHelp.setText( BaseMessages.getString( PKG, "System.Button.Help" ) );
btnHelp.setToolTipText( BaseMessages.getString( PKG, "System.Tooltip.Help" ) );
btnHelp.setLayoutData( fd_btnHelp );
btnHelp.addSelectionListener( new SelectionAdapter() {
@Override
public void widgetSelected( SelectionEvent evt ) {
代码示例来源:origin: pentaho/pentaho-kettle
@Override
protected Control addAdditionalComponentIfNeed( int middle, int margin, Composite wFileComp, Composite topComp ) {
// Run this as a command instead?
wlFileIsCommand = new Label( wFileComp, SWT.RIGHT );
wlFileIsCommand
.setText( BaseMessages.getString( textFileOutputLegacyMetaClass, "TextFileOutputLegacyDialog.FileIsCommand.Label" ) );
props.setLook( wlFileIsCommand );
fdlFileIsCommand = new FormData();
fdlFileIsCommand.left = new FormAttachment( 0, 0 );
fdlFileIsCommand.top = new FormAttachment( topComp, margin );
fdlFileIsCommand.right = new FormAttachment( middle, -margin );
wlFileIsCommand.setLayoutData( fdlFileIsCommand );
wFileIsCommand = new Button( wFileComp, SWT.CHECK );
props.setLook( wFileIsCommand );
fdFileIsCommand = new FormData();
fdFileIsCommand.left = new FormAttachment( middle, 0 );
fdFileIsCommand.top = new FormAttachment( topComp, margin );
fdFileIsCommand.right = new FormAttachment( 100, 0 );
wFileIsCommand.setLayoutData( fdFileIsCommand );
wFileIsCommand.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent e ) {
input.setChanged();
enableParentFolder();
}
} );
return wlFileIsCommand;
}
代码示例来源:origin: pentaho/pentaho-kettle
public void open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell( parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.SHEET | SWT.RESIZE );
shell.setImage( GUIResource.getInstance().getImageSpoon() );
props.setLook( shell );
fdMessage.left = new FormAttachment( wlImage, 15, SWT.RIGHT );
Button spacer = new Button( shell, SWT.NONE );
spacer.setLayoutData( fdSpacer );
spacer.setVisible( false );
props.setLook( spacer );
Button wButton = new Button( shell, SWT.PUSH );
wButton.setText( label );
wButton.setLayoutData( fdButton );
wButton.addListener( SWT.Selection, listenAndDispose( listenerMap.get( label ) ) );
props.setLook( wButton );
attachTo = wButton;
if ( !display.readAndDispatch() ) {
display.sleep();
代码示例来源:origin: pentaho/pentaho-kettle
Label label = new Label( perfComposite, SWT.CENTER );
label.setText( BaseMessages.getString( PKG, "TransLog.Dialog.PerformanceMonitoringNotEnabled.Message" ) );
label.setBackground( perfComposite.getBackground() );
label.setFont( GUIResource.getInstance().getFontMedium() );
fdLabel.left = new FormAttachment( 5, 0 );
fdLabel.right = new FormAttachment( 95, 0 );
fdLabel.top = new FormAttachment( 5, 0 );
label.setLayoutData( fdLabel );
Button button = new Button( perfComposite, SWT.CENTER );
button.setText( BaseMessages.getString( PKG, "TransLog.Dialog.PerformanceMonitoring.Button" ) );
button.setBackground( perfComposite.getBackground() );
button.setFont( GUIResource.getInstance().getFontMedium() );
button.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent event ) {
TransGraph.editProperties(
fdButton.right = new FormAttachment( 60, 0 );
fdButton.top = new FormAttachment( label, 5 );
button.setLayoutData( fdButton );
代码示例来源:origin: pentaho/pentaho-kettle
public void open() {
shell = new Shell( parentShell, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN );
props.setLook( shell );
shell.setImage( GUIResource.getInstance().getImageSpoon() );
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout( formLayout );
shell.setText( dialogTitle );
wClose = new Button( shell, SWT.PUSH );
wClose.setText( BaseMessages.getString( PKG, "System.Button.Close" ) );
wClose.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
close();
while ( !shell.isDisposed() ) {
if ( !shell.getDisplay().readAndDispatch() ) {
shell.getDisplay().sleep();
代码示例来源:origin: pentaho/pentaho-kettle
protected void addFileWidgets() {
Label wlLocation = new Label( this, SWT.RIGHT );
wlLocation.setText( BaseMessages.getString( PKG, "VfsFileChooserControls.Location.Label" ) );
wlLocation.setLayoutData( new FormDataBuilder( ).left( 0, 0 ).top( 0, 0 ).result() );
wLocation = new CCombo( this, SWT.BORDER | SWT.READ_ONLY );
List<VFSScheme> availableVFSSchemes = getAvailableVFSSchemes();
wPath.setLayoutData( new FormDataBuilder().left( 0, 0 ).top( wlPath, FIELD_LABEL_SEP ).width( FIELD_LARGE + VAR_EXTRA_WIDTH ).result() );
wbBrowse = new Button( this, SWT.PUSH );
wbBrowse.setText( BaseMessages.getString( PKG, "System.Button.Browse" ) );
wbBrowse.addListener( SWT.Selection, event -> browseForFileInputPath() );
int bOffset = ( wbBrowse.computeSize( SWT.DEFAULT, SWT.DEFAULT, false ).y
- wPath.computeSize( SWT.DEFAULT, SWT.DEFAULT, false ).y ) / 2;
wbBrowse.setLayoutData( new FormDataBuilder().left( wPath, FIELD_LABEL_SEP ).top( wlPath, FIELD_LABEL_SEP - bOffset ).result() );
代码示例来源:origin: pentaho/pentaho-kettle
private void fillLocalizationData() {
labelDimension.setText( BaseMessages.getString( PKG, "PaloDimInputDialog.SelectDimension" ) );
labelStepName.setText( BaseMessages.getString( PKG, "PaloDimInputDialog.StepName" ) );
shell.setText( BaseMessages.getString( PKG, "PaloDimInputDialog.PaloDimInput" ) );
buttonGetLevels.setText( BaseMessages.getString( PKG, "PaloDimInputDialog.GetLevels" ) );
buttonClearLevels.setText( BaseMessages.getString( PKG, "PaloDimInputDialog.ClearLevels" ) );
labelBaseElementsOnly.setText( BaseMessages.getString( PKG, "PaloDimInputDialog.BaseElementsOnly" ) );
}
代码示例来源:origin: pentaho/pentaho-kettle
public Composite getComposite( Composite parent, ImportRuleInterface importRule ) {
rule = (DatabaseConfigurationImportRule) importRule;
databaseMeta = rule.getDatabaseMeta();
PropsUI props = PropsUI.getInstance();
composite = new Composite( parent, SWT.NONE );
props.setLook( composite );
composite.setLayout( new FillLayout() );
label = new Label( composite, SWT.SINGLE | SWT.BORDER | SWT.LEFT );
props.setLook( label );
label.setText( "Database configuration : (not configured)" );
button = new Button( composite, SWT.PUSH );
button.setText( "Edit..." );
button.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent event ) {
editDatabase();
}
} );
return composite;
}
代码示例来源:origin: pentaho/pentaho-kettle
protected Button createSettingsButton( Composite p, String text, String title, Control top, SelectionAdapter sa ) {
Button button = new Button( p, SWT.CHECK );
button.setText( BaseMessages.getString( PKG, text ) );
button.setToolTipText( BaseMessages.getString( PKG, title ) );
props.setLook( button );
FormData fd = new FormData();
fd.left = new FormAttachment( 0, Const.MARGIN * 2 );
if ( top == null ) {
fd.top = new FormAttachment( 0, 10 );
} else {
fd.top = new FormAttachment( top, 5 );
}
fd.right = new FormAttachment( 100, 0 );
button.setLayoutData( fd );
button.addSelectionListener( sa );
return button;
}
代码示例来源:origin: pentaho/pentaho-kettle
private static Button newButton( final Composite parent ) {
Button button = new Button( parent, SWT.PUSH );
button.setImage( GUIResource.getInstance().getImageHelpWeb() );
button.setText( BaseMessages.getString( PKG, "System.Button.Help" ) );
button.setToolTipText( BaseMessages.getString( PKG, "System.Tooltip.Help" ) );
FormData fdButton = new FormData();
fdButton.left = new FormAttachment( 0, 0 );
fdButton.bottom = new FormAttachment( 100, 0 );
button.setLayoutData( fdButton );
return button;
}
内容来源于网络,如有侵权,请联系作者删除!