Force JEditorPane within JScrollPane to shrink + re-wrap
问题 Having an issue with a JScrollPane expanding its child JEditorPane just fine but forcing horizontal scroll bars when resizing it down again (instead of forcing the JEditorPane to recalculate wrapping). The basic flow of code is as follows: JFrame f = new JFrame(); JEditorPane jep = new JEditorPane(); JScrollPane jsp = new JScrollPane(jep); f.add(jsp); 回答1: It's a hack, but the best way I could find (without using ugly ScrollPaneManager s) was to implement a ComponentListener on the