Friday 15 June 2012

java - Changing Font/Size/Color/Format of highlighted text in InlineCSSTextArea javafX -



java - Changing Font/Size/Color/Format of highlighted text in InlineCSSTextArea javafX -

i able have user highlight text, , alter font or size or color or format (bold, underline, italicize) of highlighted text.

boolean b = isbold(); boolean u = isunderlined(); boolean = isitalicized(); string colorhexvalue = getcolorvalue(); string f = (string)getfont(); int size = getsize(); font font = new font(f, size); inlinecsstextarea newarea = new inlinecsstextarea();

i aware can

newarea.getselectedtext();

in order test highlighted. however, returns string. ideally, this:

newarea.getselectedtext().setfont(font);

but not work because selected text string, not cssinlinetextarea. how go setting selected text font/size/color/format want? feeling i'll need css, i'm not sure how apply highlighted text, nor write css.

assuming talking inlinecsstextarea richtextfx, utilize combination of getselection() , setstyle(from, to, style):

indexrange selection = newarea.getselection(); newarea.setstyle(selection.getstart(), selection.getend(), "-fx-font-family: helvetica");

if don't want utilize css, rather utilize java api straight set properties, have utilize styledtextarea straight instead of subclass inlinecsstextarea.

java css javafx

No comments:

Post a Comment