JEditorPane + MouseWheel
So I have a JEditorPane inside a JScrollPane. I can scroll up and down just fine when my mouse is hovering over the JScrollPane (literally the scroll bars). However, when the mouse is hovering over the JEditorPane it will not scroll even though there scrolling is possible.
Any tips on the relationship between these two components, and how I can basically take any MouseWheelEvents that happen in the JEditorPane and transfer them to the JScrollPane?
Thanks in advance.
Could you post a minimal example illustrating this?
The TextSamplerDemo class in Oracle's Tutorial creates a JEditorPane instance and passes this to the JScrollPane constructor and scrolling works as expected. Perhaps you mean something different by "a JEditorPane inside a JScrollPane".
Thanks for the reply. After reviewing my post and reviewing the code I was a bit off in my explanation of what I have going on. I actually had a JScrollPane which contained a JPanel. That JPanel contains a JScrollPane which holds a JEditorPane. I'm still not entirely sure why I'm saw this effect, but when I did not set the preferred size on the JScrollPane (the one that held my JEditorPane), the JScrollPane which held the JPanel had its VerticalScrollBar showing. So in other words, my entire text file was being displayed in the JPanel's JScrollPane with NO scrolling required. Once I set the Preferred SIze on that JScrollPane (to anything, 0,0 or 200, 200 etc) it began to size itself to the JPanel and displaying its ScrollBar.
I know it sounds complicated. And I'm probably not doing it entirely the best way but I'm experimenting and learning a good chunk :)
Thanks for the help. The example you mentioned from Orcale pointed me in the right direction for where I was going wrong.