Package org.eclipse.jface.widgets
Class TextFactory
java.lang.Object
org.eclipse.jface.widgets.AbstractWidgetFactory<TextFactory,Text,Composite>
  
org.eclipse.jface.widgets.AbstractControlFactory<TextFactory,Text>
 
org.eclipse.jface.widgets.TextFactory
This class provides a convenient shorthand for creating and initializing
 
Text. This offers several benefits over creating Text normal way:
 - The same factory can be used many times to create several Text instances
- The setters on TextFactory all return "this", allowing them to be chained
- TextFactory accepts a Lambda for SelectionEvent(seeonSelect(java.util.function.Consumer<org.eclipse.swt.events.SelectionEvent>))
 Text text = new TextFactory(SWT.WRAP)//
                .limitTo(16) //
                .message("Enter credit card number") //
                .layoutData(gridData) //
                .create(parent);
 
 The above example creates a Text with wrapped style, limits it to 16 characters, sets a message and finally creates it in "parent".
 TextFactory textFactory = new TextFactory(SWT.NONE);
 textFactory.message("Enter text 1").create(parent);
 textFactory.message("Enter text 2").create(parent);
 textFactory.message("Enter text 3").create(parent);
 
 The above example creates three texts using the same instance of TextFactory.
- Since:
- 3.18
- 
Method SummaryModifier and TypeMethodDescriptionlimitTo(int limit) Sets the maximum number of characters that the receiver is capable of holding to be the argument.Sets the widget message.static TextFactorynewText(int style) Creates a new TextFactory with the given style and text.onModify(ModifyListener listener) Adds the listener to the collection of listeners who will be notified when the receiver's text is modified, by calling the modifyText method.onSelect(Consumer<SelectionEvent> consumer) Creates aSelectionListenerand registers it for the widgetSelected event.onVerify(VerifyListener listener) Adds the listener to the collection of listeners who will be notified when the receiver's text is verified, by calling the verifyText method.Sets the contents of the receiver to the given string.Methods inherited from class org.eclipse.jface.widgets.AbstractControlFactorybackground, enabled, font, foreground, layoutData, orientation, supplyLayoutData, tooltipMethods inherited from class org.eclipse.jface.widgets.AbstractWidgetFactoryaddProperty, cast, create, data, data
- 
Method Details- 
newTextCreates a new TextFactory with the given style and text. Refer toText(Composite, int)for possible styles.- Returns:
- a new TextFactory instance
- See Also:
 
- 
textSets the contents of the receiver to the given string.- Parameters:
- text- the text
- Returns:
- this
- See Also:
 
- 
messageSets the widget message. The message text is displayed as a hint for the user, indicating the purpose of the field.- Parameters:
- message- the message
- Returns:
- this
- See Also:
 
- 
limitToSets the maximum number of characters that the receiver is capable of holding to be the argument.Instead of trying to set the text limit to zero, consider creating a read-only text widget. - Parameters:
- limit- the text limit
- Returns:
- this
- See Also:
 
- 
onSelectCreates aSelectionListenerand registers it for the widgetSelected event. If the receiver is selected by the user the given consumer is invoked. TheSelectionEventis passed to the consumer.- Parameters:
- consumer- the consumer whose accept method is called
- Returns:
- this
- See Also:
 
- 
onModifyAdds the listener to the collection of listeners who will be notified when the receiver's text is modified, by calling the modifyText method.Can be called several times to add more than one ModifyListener. - Parameters:
- listener- the listener which should be notified
- Returns:
- this
- See Also:
 
- 
onVerifyAdds the listener to the collection of listeners who will be notified when the receiver's text is verified, by calling the verifyText method.Can be called several times to add more than one VerifyListener. - Parameters:
- listener- the listener which should be notified
- Returns:
- this
- See Also:
 
 
-