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:

  1. make tabs set properly.
  2. 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

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -