I have issue with JTextPane. If I write something to JTextPane on last line, the last line has another size than other previous lines. After pressing ENTER row moves a little up. I figured out, that this behavior is just in case when font size is smaller then 12. Last line can't be smaller then some size. Do you know, how to eliminate this odd behavior?
There is my SSCCE:
JFrame frame = new JFrame();
frame.setSize(350, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTextPane pane = new JTextPane();
MutableAttributeSet attrs = new SimpleAttributeSet();
StyleConstants.setFontSize(attrs, 11);
pane.setCharacterAttributes(attrs, false);
frame.add(pane);
frame.setVisible(true);
That's because the last paragraph's attributes. It has default attributes and default font size is 12. To fix try to apply the character attributes to the last \n char.
StyledDocument doc=(StyledDocument)pane.getDocument();
doc.setCharacterAttributes(0, doc.getLength()+1, attrs, false);
Yes. The lenght+1 to include the last char after in the end of the Document.