本文整理了Java中org.eclipse.swt.widgets.Label.setText()
方法的一些代码示例,展示了Label.setText()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Label.setText()
方法的具体详情如下:
包路径:org.eclipse.swt.widgets.Label
类名称:Label
方法名:setText
[英]Sets the receiver's text.
This method sets the widget label. The label may include the mnemonic character and line delimiters.
Mnemonics are indicated by an '&' that causes the next character to be the mnemonic. When the user presses a key sequence that matches the mnemonic, focus is assigned to the control that follows the label. On most platforms, the mnemonic appears underlined but may be emphasised in a platform specific manner. The mnemonic indicator character '&' can be escaped by doubling it in the string, causing a single '&' to be displayed.
Note: If control characters like '\n', '\t' etc. are used in the string, then the behavior is platform dependent.
[中]设置接收者的文本。
此方法设置小部件标签。标签可以包括助记字符和行分隔符。
助记符由“&”表示,它使下一个字符成为助记符。当用户按下与助记符匹配的键序列时,焦点将分配给标签后面的控件。在大多数平台上,助记符带下划线,但可能会以特定于平台的方式进行强调。助记指示符“&”可以通过在字符串中加倍来转义,从而显示单个“&”。
注意:如果字符串中使用了诸如“\n”、“t”等控制字符,则该行为取决于平台。
代码示例来源:origin: pentaho/pentaho-kettle
/**
* Create label.
*
* @param style
* style to use.
* @param text
* text to set.
* @return new label.
*/
public Label createLabel( final int style, final String text ) {
final Label label = new Label( this.shell, style );
label.setText( text );
return label;
}
代码示例来源:origin: caoxinyu/RedisClient
@Override
protected void initData(Composite dataComposite) {
Label label = new Label(dataComposite, SWT.NONE);
label.setText(RedisClient.i18nFile.getText(I18nFile.VALUE));
label.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 1, 1));
text_value = new Text(dataComposite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
text_value.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
}
public Text getText() {
代码示例来源: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 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 layoutComposite() {
FormLayout flAuthComp = new FormLayout();
this.setLayout( flAuthComp );
wAuthGroup.setText( authGroupLabel );
FormLayout flAuthGroup = new FormLayout();
flAuthGroup.marginHeight = 15;
flAuthGroup.marginWidth = 15;
wlUsername = new Label( wAuthGroup, SWT.LEFT );
props.setLook( wlUsername );
wlUsername.setText( usernameLabel );
wlUsername.setLayoutData( new FormDataBuilder().left().top().result() );
wlPassword = new Label( wAuthGroup, SWT.LEFT );
props.setLook( wlPassword );
wlPassword.setText( passwordLabel );
wlPassword.setLayoutData( new FormDataBuilder().left().top( wUsername, ConstUI.MEDUIM_MARGIN ).result() );
代码示例来源:origin: pentaho/pentaho-kettle
public LabelText( Composite composite, int textStyle, String labelText, String toolTipText, int middle,
int margin ) {
super( composite, SWT.NONE );
props.setLook( this );
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = 0;
formLayout.marginHeight = 0;
this.setLayout( formLayout );
wText = new Text( this, textStyle );
FormData fdText = new FormData();
fdText.left = new FormAttachment( middle, margin );
fdText.right = new FormAttachment( 100, 0 );
wText.setLayoutData( fdText );
wText.setToolTipText( toolTipText );
wLabel = new Label( this, SWT.RIGHT );
props.setLook( wLabel );
wLabel.setText( labelText );
FormData fdLabel = new FormData();
fdLabel.left = new FormAttachment( 0, 0 );
fdLabel.right = new FormAttachment( middle, 0 );
fdLabel.top = new FormAttachment( wText, 0, SWT.CENTER );
wLabel.setLayoutData( fdLabel );
wLabel.setToolTipText( toolTipText );
}
代码示例来源: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
btnOk.setText(RedisClient.i18nFile.getText(I18nFile.OK));
代码示例来源:origin: pentaho/pentaho-kettle
private Label addStandardLabel( String messageString, Control previousControl ) {
Label label = new Label( shell, SWT.RIGHT );
label.setText( messageString );
label.setLayoutData( standardLabelSpacing( previousControl, label ) );
props.setLook( label );
return label;
}
代码示例来源:origin: caoxinyu/RedisClient
protected void initObjectTabItem() {
RedisObject object = service.getObjectInfo(id, db, key);
objectTabItem = new TabItem(tabFolder, SWT.NONE);
objectTabItem.setText(RedisClient.i18nFile.getText(I18nFile.OBJECT));
Composite objectComposite = new Composite(tabFolder, SWT.NONE);
objectTabItem.setControl(objectComposite);
objectComposite.setLayout(new GridLayout(4, true));
label1 = new Label(objectComposite, SWT.NONE);
label1.setText(RedisClient.i18nFile.getText(I18nFile.REFCOUNT));
Label label_1 = new Label(objectComposite, SWT.NONE);
label_1.setText(object.getRefCount().toString());
label2 = new Label(objectComposite, SWT.NONE);
label2.setText(RedisClient.i18nFile.getText(I18nFile.ENCODING));
Label label_2 = new Label(objectComposite, SWT.NONE);
label_2.setText(object.getEncoding());
}
代码示例来源:origin: pentaho/pentaho-kettle
private void placeControl( Shell pShell, String text, Control control, Control under ) {
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
Label label = new Label( pShell, SWT.RIGHT );
label.setText( text );
props.setLook( label );
FormData formDataLabel = new FormData();
formDataLabel.left = new FormAttachment( 0, 0 );
if ( under != null ) {
formDataLabel.top = new FormAttachment( under, margin );
} else {
formDataLabel.top = new FormAttachment( 0, 0 );
}
formDataLabel.right = new FormAttachment( middle, 0 );
label.setLayoutData( formDataLabel );
props.setLook( control );
FormData formDataControl = new FormData();
formDataControl.left = new FormAttachment( middle, 0 );
if ( under != null ) {
formDataControl.top = new FormAttachment( under, margin );
} else {
formDataControl.top = new FormAttachment( 0, 0 );
}
formDataControl.right = new FormAttachment( 100, 0 );
control.setLayoutData( formDataControl );
}
代码示例来源:origin: caoxinyu/RedisClient
composite.setLayout(new GridLayout(2, false));
btnExpire = new Button(composite, SWT.CHECK);
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));
代码示例来源:origin: pentaho/pentaho-kettle
private Label addStandardLabel( String messageString, Control previousControl ) {
Label label = new Label( shell, SWT.RIGHT );
label.setText( messageString );
label.setLayoutData( standardLabelSpacing( previousControl ) );
props.setLook( label );
return label;
}
代码示例来源:origin: pentaho/pentaho-kettle
public Composite getComposite( Composite parent, ImportRuleInterface importRule ) {
PropsUI props = PropsUI.getInstance();
composite = new Composite( parent, SWT.NONE );
props.setLook( composite );
composite.setLayout( new FillLayout() );
Label label = new Label( composite, SWT.SINGLE | SWT.BORDER | SWT.LEFT );
props.setLook( label );
label.setText( "Minimum length: " );
text = new Text( composite, SWT.SINGLE | SWT.BORDER | SWT.LEFT );
props.setLook( text );
return composite;
}
代码示例来源:origin: pentaho/pentaho-kettle
protected void runConfigurationSectionLayout( Class<?> PKG, String prefix ) {
cRunConfiguration = new Composite( shell, SWT.NONE );
cRunConfiguration.setLayout( new FormLayout() );
props.setLook( cRunConfiguration );
FormData fdLocal = new FormData();
fdLocal.top = new FormAttachment( 0, 15 );
fdLocal.right = new FormAttachment( 100, -15 );
fdLocal.left = new FormAttachment( 0, 15 );
cRunConfiguration.setBackground( shell.getBackground() ); // the default looks ugly
cRunConfiguration.setLayoutData( fdLocal );
Label wlRunConfiguration = new Label( cRunConfiguration, SWT.LEFT );
props.setLook( wlRunConfiguration );
wlRunConfiguration.setText( "Run configuration:" );
FormData fdlRunConfiguration = new FormData();
fdlRunConfiguration.top = new FormAttachment( 0 );
fdlRunConfiguration.left = new FormAttachment( 0 );
wlRunConfiguration.setLayoutData( fdlRunConfiguration );
wRunConfiguration = new CCombo( cRunConfiguration, SWT.BORDER );
props.setLook( wRunConfiguration );
FormData fdRunConfiguration = new FormData();
fdRunConfiguration.width = 200;
fdRunConfiguration.top = new FormAttachment( wlRunConfiguration, 5 );
fdRunConfiguration.left = new FormAttachment( 0 );
wRunConfiguration.setLayoutData( fdRunConfiguration );
}
代码示例来源:origin: caoxinyu/RedisClient
ttlComposite.setLayout(new GridLayout(2, false));
btnExpire = new Button(ttlComposite, SWT.CHECK);
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));
代码示例来源:origin: pentaho/pentaho-kettle
@Override
protected Control buildBody() {
final Label message = new Label( shell, SWT.WRAP | SWT.LEFT );
message.setText( this.message );
props.setLook( message );
message.setLayoutData( new FormDataBuilder().top().left().right( 100, 0 ).result() );
return message;
}
}
代码示例来源:origin: pentaho/pentaho-kettle
@Override
protected Control createMessageArea( Composite composite ) {
GridLayout gridLayout = (GridLayout) composite.getLayout();
gridLayout.numColumns = 1;
composite.setLayout( gridLayout );
if ( this.message != null ) {
this.messageLabel = new Label( composite, this.getMessageLabelStyle() );
this.messageLabel.setText( this.message );
}
if ( this.details != null ) {
this.detailsText = new Text( composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL );
this.detailsText.pack();
this.detailsText.setText( this.details );
GridData gridData = new GridData( );
gridData.widthHint = 1024;
gridData.heightHint = 300;
this.detailsText.setLayoutData( gridData );
this.detailsText.setSelection( this.details.length() );
}
return composite;
}
代码示例来源:origin: pentaho/pentaho-kettle
private Text createLine( ModifyListener lsMod, String lableText, Control prevControl ) {
// Value line
Label lable = new Label( shell, SWT.RIGHT );
lable.setText( lableText );
props.setLook( lable );
FormData lableFormData = new FormData();
lableFormData.left = new FormAttachment( 0, 0 );
lableFormData.right = new FormAttachment( props.getMiddlePct(), -Const.MARGIN );
// In case it is the first control
if ( prevControl != null ) {
lableFormData.top = new FormAttachment( prevControl, Const.MARGIN );
} else {
lableFormData.top = new FormAttachment( 0, Const.MARGIN );
}
lable.setLayoutData( lableFormData );
Text control = new Text( shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
props.setLook( control );
control.addModifyListener( lsMod );
FormData widgetFormData = new FormData();
widgetFormData.left = new FormAttachment( props.getMiddlePct(), 0 );
// In case it is the first control
if ( prevControl != null ) {
widgetFormData.top = new FormAttachment( prevControl, Const.MARGIN );
} else {
widgetFormData.top = new FormAttachment( 0, Const.MARGIN );
}
widgetFormData.right = new FormAttachment( 100, 0 );
control.setLayoutData( widgetFormData );
return control;
}
代码示例来源:origin: pentaho/pentaho-kettle
@Override
protected Control buildBody() {
final Label message = new Label( shell, SWT.WRAP | SWT.LEFT );
message.setText( BaseMessages.getString( PKG, "System.GetFields.NewFieldsFound.Message", numFields ) );
props.setLook( message );
message.setLayoutData( new FormDataBuilder().top().left().right( 100, 0 ).result() );
final Button newFieldsOnly = new Button( shell, SWT.RADIO );
newFieldsOnly.setSelection( true );
props.setLook( newFieldsOnly );
newFieldsOnly.setText( BaseMessages.getString( PKG, "System.GetFields.AddNewOnly.Label" ) );
newFieldsOnly.setLayoutData( new FormDataBuilder().top( message, MARGIN_SIZE ).left().result() );
final Button clearAndAddAll = new Button( shell, SWT.RADIO );
props.setLook( clearAndAddAll );
clearAndAddAll.setText( BaseMessages.getString( PKG, "System.GetFields.ClearAndAddAll.Label" ) );
clearAndAddAll.setLayoutData( new FormDataBuilder().top( newFieldsOnly, ELEMENT_SPACING ).left().result() );
代码示例来源:origin: pentaho/pentaho-kettle
private void buildHeader() {
buildPreHeader();
// Step icon
final Label wicon = new Label( shell, SWT.RIGHT );
wicon.setImage( getImage() );
wicon.setLayoutData( new FormDataBuilder().top( 0, -BaseDialog.LABEL_SPACING ).right( 100, 0 ).result() );
props.setLook( wicon );
// Step name label
wlStepname = new Label( shell, SWT.RIGHT );
wlStepname.setText( BaseMessages.getString( PKG, "CommonStepDialog.Stepname.Label" ) ); //$NON-NLS-1$
props.setLook( wlStepname );
fdlStepname = new FormDataBuilder().left( 0, 0 ).top( 0, -BaseDialog.LABEL_SPACING ).result();
wlStepname.setLayoutData( fdlStepname );
// Step name field
wStepname = new Text( shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
wStepname.setText( stepname );
props.setLook( wStepname );
wStepname.addModifyListener( lsMod );
wStepname.addSelectionListener( lsDef );
fdStepname = new FormDataBuilder().width( BaseDialog.MEDIUM_FIELD ).left( 0, 0 ).top(
wlStepname, BaseDialog.LABEL_SPACING ).result();
wStepname.setLayoutData( fdStepname );
// horizontal separator between step name and tabs
headerSpacer = new Label( shell, SWT.HORIZONTAL | SWT.SEPARATOR );
props.setLook( headerSpacer );
headerSpacer.setLayoutData( new FormDataBuilder().left().right( 100, 0 ).top(
wStepname, BaseDialog.MARGIN_SIZE ).width( SHELL_WIDTH - 2 * ( BaseDialog.MARGIN_SIZE ) ).result() );
buildPostHeader();
}
内容来源于网络,如有侵权,请联系作者删除!