java - Blurry Text after setting StyleConstants.setFirstLineIndent as negative in Swing -


im newbie swing applications. need add firstlineindent text , after setting value negative paragraph's first line seems little blurry. unable recognize behavior of styleconstants.setfirstlineindent(attr,-50) method. how rectify error.

below link of code using reference:

http://java-sl.com/tip_hanging_first_line.html

thanks...

not sure why example extends jeditorpane. editor pane html. prefer use jtextpane styled text. don't know why custom editor kit used.

the following code works me:

import javax.swing.*; import javax.swing.text.*; import java.awt.*;  //public class hangingindent extends jeditorpane { public class hangingindent extends jtextpane {      public static void main(string[] args) {         jframe frame = new jframe("negative (hanging) first line indent");         frame.setdefaultcloseoperation(jframe.exit_on_close);         final hangingindent app = new hangingindent(); //        app.seteditorkit(new myeditorkit());         app.settext("the paragraph long text necessary show how " +                 "hanging indent can achieved. should set not " +                 "first line indent same left indent.");         styleddocument doc=(styleddocument)app.getdocument();         simpleattributeset attrs=new simpleattributeset();         styleconstants.setfirstlineindent(attrs, -50);         styleconstants.setleftindent(attrs, 50);          doc.setparagraphattributes(0,doc.getlength(),attrs, false);          jscrollpane scroll = new jscrollpane(app);         frame.getcontentpane().add(scroll);          frame.setsize(400, 200);         frame.setlocationrelativeto(null);         frame.setvisible(true);     }      public hangingindent() {         super();     } } 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -