Based on existing solutions, I did not find a way to force JTextPane (or JEditorPane) to have either word wrap or forced line wrapping inside JScrollPane. JTextArea is not a solution, since I need HTML to display in a specific input.
output = new JTextPane();
scrollPane.setViewportView(output);
contentPane.add(scrollPane, gbc_scrollPane);
output.setEditorKit(new WrapEditorKit());
output.setForeground(Color.WHITE);
output.setFont(new Font("Courier New", Font.PLAIN, 12));
output.setEditable(false);
output.setContentType("text/html; charset=UTF-8");
output.setBackground(Color.DARK_GRAY);
WrapEditorKit is the only one available here . I also tried ScrollablePanel, but every time the JTextPane text is not wrapped at all. How can I combine a JTextPane inside a JScrollPane with a vertical scroll (and horizontal word or forced line break )?
source
share