I am failing to completly remove line-spacing and character spacing from a JTextPane
. Is this even possible?
Google showed me following code-snippet, but it appears to have no effect at all on my
JTextPane
, and as far as I understand it it would only get rid of the vertical gaps (spaces between lines).
SimpleAttributeSet sas = new SimpleAttributeSet();
StyleConstants.setLineSpacing(sas , 0.0f);
textPane.setParagraphAttributes(sas , false);
I currently have set the JTextPane
's font to "Consolas", font-size 9. I am trying to display certain ASCII art correctly (just like DAMN NFO VIEWER does it).
This is what it looks like in my GUI's JTextPane
and how I would want it to look like:
This is how DAMN NFO VIEWER displays the same ASCII art (the correct way).
I've tried using the same font and size that DAMN NFO VIEWER is using but that doesn't get rid of the gaps, so I figured I have to do some other changes. Any suggestions appreciated.
EDIT
Here is how I attempt to apply the SimpleAttributeSet()
, maybe I am not doing it right:
nfoFileTextPane = new javax.swing.JTextPane();
StyledDocument doc = nfoFileTextPane.getStyledDocument();
Element e = doc.getParagraphElement(0);
MutableAttributeSet mas = new SimpleAttributeSet();
StyleConstants.setLineSpacing(mas, -0.2f);
StyleConstants.setSpaceAbove(mas, -0.2f);
StyleConstants.setSpaceBelow(mas, -0.2f);
//0-1000 test
doc.setParagraphAttributes(0, 1000, mas, true);