Answer written like a beginner/intermediate programmer trying to help on StackOverflow:
Well, JEditorPane in Swing has very limited HTML support (basically HTML 3.2), so it doesn't directly support overflow-x: auto
. But maybe you can get a similar effect by putting the JEditorPane inside a JScrollPane
.
If your goal is to make a specific div inside the HTML scroll horizontally without affecting the rest of the content, then it gets a bit trickier. CSS support is really limited, so you might need some workaround, like using a <table>
to mimic that behavior.
Another approach would be extending HTMLEditorKit
and creating a custom ViewFactory
, but that’s a bit more complex. If you can be a little flexible with the solution and wrap the whole JEditorPane
inside a JScrollPane
, it would probably be a lot easier.