2
Using Jpanel you could do so:
StyledDocument doc = textPane.getStyledDocument();
SimpleAttributeSet center = new SimpleAttributeSet();
StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
doc.setParagraphAttributes(0, doc.getLength(), center, false);
Hello, he went in the middle, but you know some way to get him aligned according to size
width
ofJTextPane
??– Lucas Caresia