How do I make a JTextPane have a different tab size in Java? -
i have jtextpane, have noticed if use .settext()
tabs removed.
fix see 2 options:
- make tabs set properly.
- replace tabs html special character
 
, change tab size in jtextpane match width of html tab.
i not know how #1 trying use crude hack #2. question is, how change tab size jtextpane using htmldocument, or how settext()
, not have tabs removed?
also using gettext()
, settext()
in order save text inside jtextpane.
thank in advance.
in order solve problem without method 1 or 2 have done this:
textpane.getinputmap().put(keystroke.getkeystroke("tab"), "tab"); textpane.getactionmap().put("tab", new abstractaction("tab"){ private static final long serialversionuid = -2621537943352838927l; public void actionperformed(actionevent e){ try { textpane.getdocument().insertstring(textpane.getcaretposition(), " ", null);//the " " html special character (tab) in plain text. } catch (badlocationexception e1) { e1.printstacktrace(); } } });
i found overrides default tab input.
Comments
Post a Comment