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

x33g5p2x  于2022-01-16 转载在 其他  
字(15.5k)|赞(0)|评价(0)|浏览(186)

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

Button.addSelectionListener介绍

[英]Adds the listener to the collection of listeners who will be notified when the control is selected by the user, by sending it one of the messages defined in the SelectionListener interface.

widgetSelected is called when the control is selected by the user. widgetDefaultSelected is not called.

When the SWT.RADIO style bit is set, the widgetSelected method is also called when the receiver loses selection because another item in the same radio group was selected by the user. During widgetSelected the application can use getSelection() to determine the current selected state of the receiver.
[中]通过发送SelectionListener界面中定义的消息之一,将侦听器添加到侦听器集合中,当用户选择控件时,将通知这些侦听器。
当用户选择控件时调用widgetSelected。未调用widgetDefaultSelected
当设置SWT.RADIO样式位时,由于用户选择了同一无线电组中的另一项,因此接收器丢失选择时,也会调用widgetSelected方法。在widgetSelected期间,应用程序可以使用getSelection()确定接收器的当前选定状态。

代码示例

代码示例来源:origin: caoxinyu/RedisClient

protected void initContents() {
  Composite composite_1 = new Composite(shell, SWT.NONE);
  composite_1.setLayout(new FillLayout(SWT.HORIZONTAL));
  composite_1.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false,
      false, 1, 1));
  btnOk = new Button(composite_1, SWT.NONE);
  btnOk.addSelectionListener(okSelection);
  btnOk.setText(RedisClient.i18nFile.getText(I18nFile.OK));
  Button btnCancel = new Button(composite_1, SWT.NONE);
  btnCancel.addSelectionListener(cancelSelection);
  btnCancel.setText(RedisClient.i18nFile.getText(I18nFile.CANCEL));
}

代码示例来源: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

@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

/**
 * @param factory
 *          factory to use.
 */
protected void buildUseControlFileLine( final PluginWidgetFactory factory ) {
 final Control topControl = this.wStepname;
 this.wlUseControlFile =
  factory.createRightLabel( BaseMessages.getString( PKG, "TeraFastDialog.UseControlFile.Label" ) );
 this.props.setLook( this.wlUseControlFile );
 this.wlUseControlFile.setLayoutData( factory.createLabelLayoutData( topControl ) );
 this.wUseControlFile = new Button( this.shell, SWT.CHECK );
 this.props.setLook( this.wUseControlFile );
 this.wUseControlFile.setLayoutData( factory.createControlLayoutData( topControl ) );
 this.wUseControlFile.addSelectionListener( new SelectionAdapter() {
  @Override
  public void widgetSelected( final SelectionEvent event ) {
   disableInputs();
  }
 } );
}

代码示例来源: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

protected Button addStandardCheckBox( String labelMessageKey, Control prevControl ) {
 Label label = addStandardLabel( labelMessageKey, prevControl );
 Button targetControl = new Button( shell, SWT.CHECK );
 props.setLook( targetControl );
 targetControl.addSelectionListener( new SelectionAdapter() {
  public void widgetSelected( SelectionEvent e ) {
   input.setChanged();
  }
 } );
 targetControl.setLayoutData( standardInputSpacing( prevControl, label ) );
 return targetControl;
}

代码示例来源:origin: caoxinyu/RedisClient

public UpdateTTLTabItem(TabFolder parent, final int id, final int db, final String key) {
  super(parent);
  new Label(composite, SWT.NONE);
  btnApplyButton = new Button(composite, SWT.NONE);
  btnApplyButton.addSelectionListener(new SelectionAdapter() {
    @Override
    public void widgetSelected(SelectionEvent e) {
  btnApplyButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
  btnApplyButton.setText(RedisClient.i18nFile.getText(I18nFile.APPLY));
  btnApplyButton.setEnabled(false);
  btnExpire.addSelectionListener(new SelectionAdapter() {
    @Override
    public void widgetSelected(SelectionEvent e) {

代码示例来源: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

private void buildWidget() {
 wCheckBox = new Button( parentComposite, SWT.CHECK );
 wCheckBox.setText( buttonName );
 props.setLook( wCheckBox );
 FormData fdUseSSL = new FormData();
 fdUseSSL.top = new FormAttachment( parentComposite, 0 );
 fdUseSSL.left = new FormAttachment( 0, 0 );
 wCheckBox.setLayoutData( fdUseSSL );
 wCheckBox.addSelectionListener( new SelectionListener() {
  @Override public void widgetSelected( SelectionEvent selectionEvent ) {
   boolean selection = ( (Button) selectionEvent.getSource() ).getSelection();
 Label wlSSLProperties = new Label( parentComposite, SWT.LEFT );
 wlSSLProperties.setText( tableName );
 props.setLook( wlSSLProperties );
 FormData fdlSSLProperties = new FormData();
 fdlSSLProperties.top = new FormAttachment( wCheckBox, 10 );
 fdlSSLProperties.left = new FormAttachment( 0, 0 );
 wlSSLProperties.setLayoutData( fdlSSLProperties );

代码示例来源:origin: pentaho/pentaho-kettle

public Composite createContent( String radioText ) {
 Control[] existingButtons = radioGroup.getChildren();
 Button button = new Button( radioGroup, SWT.RADIO );
 button.setText( radioText );
 props.setLook( button );
 FormData fdButton = new FormData();
 fdButton.top = new FormAttachment( 0 );
 fdButton.left = existingButtons.length == 0
  ? new FormAttachment( 0 ) : new FormAttachment( existingButtons[existingButtons.length - 1], 40 );
 button.setLayoutData( fdButton );
 button.setSelection( existingButtons.length == 0 );
 Composite content = new Composite( contentArea, SWT.NONE );
 content.setVisible( existingButtons.length == 0 );
 props.setLook( content );
 content.setLayout( noMarginLayout );
 content.setLayoutData( fdMaximize );
 button.addSelectionListener( new SelectionAdapter() {
  @Override public void widgetSelected( SelectionEvent selectionEvent ) {
   for ( Control control : contentArea.getChildren() ) {
    control.setVisible( false );
   }
   content.setVisible( true );
  }
 } );
 return content;
}

代码示例来源:origin: caoxinyu/RedisClient

composite.setLayout(new GridLayout(2, false));
btnExpire = new Button(composite, SWT.CHECK);
btnExpire.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
btnExpire.setText(RedisClient.i18nFile.getText(I18nFile.EXPIRE));
labelTTL = new Label(composite, SWT.NONE);
labelTTL.setEnabled(false);
labelTTL.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
labelTTL.setText(RedisClient.i18nFile.getText(I18nFile.TTLS));
ttl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
btnExpire.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {

代码示例来源:origin: caoxinyu/RedisClient

ttlComposite.setLayout(new GridLayout(2, false));
btnExpire = new Button(ttlComposite, SWT.CHECK);
btnExpire.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
btnExpire.setText(RedisClient.i18nFile.getText(I18nFile.EXPIRE));
labelTTL = new Label(ttlComposite, SWT.NONE);
labelTTL.setEnabled(false);
labelTTL.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
labelTTL.setText(RedisClient.i18nFile.getText(I18nFile.TTLS));
ttl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
btnExpire.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {

代码示例来源:origin: caoxinyu/RedisClient

composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
Label lblNewLabel = new Label(composite, SWT.WRAP);
lblNewLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
lblNewLabel.setText(RedisClient.i18nFile.getText(I18nFile.DONATIONMESSAGE));
Label label = new Label(composite, SWT.NONE);
label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
label.setAlignment(SWT.CENTER);
label.setImage(code);
composite_1.setLayout(new FillLayout(SWT.HORIZONTAL));
Button btnOk = new Button(composite_1, SWT.NONE);
btnOk.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent arg0) {
btnOk.setText(RedisClient.i18nFile.getText(I18nFile.OK));

代码示例来源:origin: caoxinyu/RedisClient

text_value.setFocus();
new Label(dataComposite, SWT.NONE);
new Label(dataComposite, SWT.NONE);
composite.setLayout(new GridLayout(4, false));
btnOk = new Button(composite, SWT.NONE);
btnOk.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
btnOk.setText(RedisClient.i18nFile.getText(I18nFile.APPLY));
setApply(false);
btnOk.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
btnCancel.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
btnRefresh = new Button(composite, SWT.NONE);
btnRefresh.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
btnWatch.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {

代码示例来源:origin: caoxinyu/RedisClient

protected void initTTLTabItem() {
  super.initTTLTabItem();
  new Label(ttlComposite, SWT.NONE);
  btnApply = new Button(composite, SWT.NONE);
  btnApply.addSelectionListener(new SelectionAdapter() {
    @Override
    public void widgetSelected(SelectionEvent e) {
  btnApply.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
  btnApply.setText(RedisClient.i18nFile.getText(I18nFile.APPLY));
  setTTLApply(false);
  btnRefresh = new Button(composite, SWT.NONE);
  btnRefresh.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
  btnRefresh.setText(RedisClient.i18nFile.getText(I18nFile.REFRESH));
  btnRefresh.addSelectionListener(new SelectionAdapter() {
    @Override
    public void widgetSelected(SelectionEvent e) {
  btnExpire.addSelectionListener(new SelectionAdapter() {
    @Override
    public void widgetSelected(SelectionEvent e) {

代码示例来源:origin: pentaho/pentaho-kettle

protected Button buildGetFieldsButton( final Composite parent, final SelectionAdapter listener ) {
 // get fields button
 wGet = new Button( parent, SWT.PUSH );
 updateGetFieldsButtonStatus();
 wGet.setText( BaseMessages.getString( PKG, "CommonStepDialog.Button.GetFields" ) ); //$NON-NLS-1$
 props.setLook( wGet );
 wGet.setLayoutData( new FormDataBuilder().right( 100, 0 ).bottom( 100, 0 ).result() );
 wGet.addSelectionListener( listener );
 return wGet;
}

代码示例来源:origin: pentaho/pentaho-kettle

for ( JmsProvider.ConnectionType type : JmsProvider.ConnectionType.values() ) {
 Button connectionButton = new Button( wConnectionGroup, SWT.RADIO );
 connectionButton.setText( type.toString() );
 fdbConnType.left = new FormAttachment( 0, 0 );
 if ( previous == null ) {
  fdbConnType.top = new FormAttachment( 0, 0 );
 } else {
  fdbConnType.top = new FormAttachment( previous, 10 );
 connectionButton.setLayoutData( fdbConnType );
 connectionButton.addSelectionListener( new SelectionListener() {
  @Override public void widgetSelected( final SelectionEvent selectionEvent ) {
   lsMod.modifyText( null );
Label environmentSeparator = new Label( wConnectionGroup, SWT.SEPARATOR | SWT.VERTICAL );
fdenvironmentSeparator.left = new FormAttachment( widestWidget, 15 );
fdenvironmentSeparator.bottom = new FormAttachment( 100, 0 );
environmentSeparator.setLayoutData( fdenvironmentSeparator );

代码示例来源:origin: pentaho/pentaho-kettle

wlPassword = new Label( composite, SWT.RIGHT );
wlPassword.setText( BaseMessages.getString( PKG, "CreateDatabaseWizardPage2.Password.Label" ) );
props.setLook( wlPassword );
fdlPassword = new FormData();
fdlPassword.left = new FormAttachment( 0, 0 );
fdlPassword.right = new FormAttachment( middle, 0 );
wlPassword.setLayoutData( fdlPassword );
wPassword = new Text( composite, SWT.SINGLE | SWT.BORDER );
props.setLook( wPassword );
wTest = new Button( composite, SWT.PUSH );
wTest.setText( BaseMessages.getString( PKG, "CreateDatabaseWizardPage2.TestConnection.Button" ) );
fdTest = new FormData();
fdTest.top = new FormAttachment( wPassword, margin * 4 );
fdTest.left = new FormAttachment( 50, 0 );
wTest.setLayoutData( fdTest );
wTest.addSelectionListener( new SelectionAdapter() {
 public void widgetSelected( SelectionEvent arg0 ) {
  test();

代码示例来源:origin: pentaho/pentaho-kettle

Label wlConnection = new Label( parent, SWT.LEFT );
wlConnection.setText( BaseMessages.getString( PKG, "MonetDBBulkLoaderDialog.Connection.Label" ) );
props.setLook( wlConnection );
Button wbnConnection = new Button( parent, SWT.RIGHT );
wbnConnection.setText( BaseMessages.getString( PKG, "MonetDBBulkLoaderDialog.NewConnectionButton.Label" ) );
wbnConnection.addSelectionListener( new SelectionAdapter() {
 public void widgetSelected( SelectionEvent e ) {
  DatabaseMeta databaseMeta = new DatabaseMeta();
Button wbeConnection = new Button( parent, SWT.RIGHT );
wbeConnection.setText( BaseMessages.getString( PKG, "BaseStepDialog.EditConnectionButton.Label" ) );
wbeConnection.addSelectionListener( new SelectionAdapter() {
 public void widgetSelected( SelectionEvent e ) {
  DatabaseMeta databaseMeta = transMeta.findDatabase( wConnection.getText() );
wlConnection.setLayoutData( fdlConnection );
 fdbConnection.top = new FormAttachment( 0, 0 );
wbnConnection.setLayoutData( fdbConnection );
 fdeConnection.top = new FormAttachment( 0, 0 );
wbeConnection.setLayoutData( fdeConnection );

代码示例来源:origin: pentaho/pentaho-kettle

alwaysShowOption = new Button( shell, SWT.CHECK );
props.setLook( alwaysShowOption );
alwaysShowOption.setSelection( abstractMeta.isAlwaysShowRunOptions() );
wCancel = new Button( shell, SWT.PUSH );
FormData fd_wCancel = new FormData();
fd_wCancel.bottom = new FormAttachment( 100, -15 );
wCancel.setLayoutData( fd_wCancel );
wCancel.setText( BaseMessages.getString( PKG, "System.Button.Cancel" ) );
wCancel.addSelectionListener( new SelectionAdapter() {
 public void widgetSelected( SelectionEvent e ) {
  cancel();
wOK = new Button( shell, SWT.PUSH );
wOK.setLayoutData( fd_wOK );
wOK.setText( BaseMessages.getString( PKG, prefix + ".Button.Launch" ) );
wOK.addSelectionListener( new SelectionAdapter() {
 public void widgetSelected( SelectionEvent e ) {
  ok();
btnHelp.addSelectionListener( new SelectionAdapter() {
 @Override
 public void widgetSelected( SelectionEvent evt ) {
Label separator = new Label( shell, SWT.SEPARATOR | SWT.HORIZONTAL );
separator.setLayoutData( fd_separator );

相关文章

Button类方法