org.fxmisc.richtext.InlineCssTextField Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of richtextfx Show documentation
Show all versions of richtextfx Show documentation
Rich-text area for JavaFX
The newest version!
package org.fxmisc.richtext;
import org.fxmisc.richtext.model.SimpleEditableStyledDocument;
import javafx.scene.text.TextAlignment;
import javafx.scene.text.TextFlow;
/**
* A TextField that uses inline CSS, i.e. setStyle(String)
, to define the styles of text segments.
* Use CSS Style Class ".styled-text-field" for styling the control.
* @author Jurgen
*/
public class InlineCssTextField extends StyledTextField
{
public InlineCssTextField() {
super( "", TextFlow::setStyle, "", TextExt::setStyle, new SimpleEditableStyledDocument<>("", "") );
}
public InlineCssTextField( String text ) {
this(); replaceText( text );
getUndoManager().forgetHistory();
getUndoManager().mark();
}
@Override
protected void changeAlignment( TextAlignment txtAlign ) {
setParagraphStyle( 0, "-fx-text-alignment: "+ txtAlign );
}
}