Results 1 to 3 of 3
  1. #1
    Moncleared is offline Member
    Join Date
    Jan 2009
    Posts
    92
    Rep Power
    0

    Default JEditorPane + MouseWheel

    Heya,

    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.

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,574
    Rep Power
    12

    Default

    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".

  3. #3
    Moncleared is offline Member
    Join Date
    Jan 2009
    Posts
    92
    Rep Power
    0

    Default

    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.

Similar Threads

  1. CSS2/3 in JEditorPane?
    By DigitalMan in forum AWT / Swing
    Replies: 1
    Last Post: 04-02-2010, 11:48 AM
  2. Replies: 7
    Last Post: 12-29-2009, 02:48 PM
  3. Javascript in JEditorpane
    By Narayan15 in forum AWT / Swing
    Replies: 1
    Last Post: 03-27-2009, 06:49 PM
  4. JEditorPane Example
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 06-27-2008, 08:47 PM
  5. JEditorPane
    By drmmr11 in forum Java Applets
    Replies: 0
    Last Post: 08-02-2007, 07:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •