Or how can I make multi-line text in the JTextArea center?

    1 answer 1

    JTextArea does not support text alignment, and resize needs crutches - there is no standard solution. You can try instead of the text area to use the text editor JTextPane , there you can edit the set of text attributes, and alignment including:

     StyledDocument doc = me.getStyledDocument(); SimpleAttributeSet centerAlignment = new SimpleAttributeSet(); StyleConstants.setAlignment(centerAlignment, StyleConstants.ALIGN_CENTER); doc.setParagraphAttributes(0, doc.getLength(), centerAlignment, false); 
    • Already, of course, has long been out of date, but if it is useful, I will check - Herrgott
    • @Herrgott Well, late - better than never =) - OldTeaOwl