Results 1 to 2 of 2
- 05-12-2012, 06:34 AM #1Member
- Join Date
- Oct 2011
- Rep Power
getting mouse location on scroll panes contents
How do you get the mouse location of the contents of a scroll pane if the scroll bars are not at 0,0? I tried implementing mouse motion listener, but when i move my mouse over the content, it always calls the scroll panes mouse motion listener(both the scroll pane and content have it implemented), not the contents. then I tried manually calling the contents listener from the scroll panes, but it still only gives coordinates relative to the scroll pane, not itself. Then I tried using the getVerticalScrollBar().getValue() method to add it to the coordinates given, but the problem with that is when the scroll bar is at 0, its value is 0, but when it is at 500(the max), its value is 553 or so, so it doesnt change linearly with moving the scroll bar. Are there any suggestions to this problem? i am trying to implement a canvas you can paint on that is variable size so it needs to be in a scroll pane.
- 05-12-2012, 09:24 AM #2
Re: getting mouse location on scroll panes contents
I fail to understand any reason for adding a MouseMotionListener to a JScorllPane, but maybe you can explain how you intend to use it. To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.
(both the scroll pane and content have it implemented)
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
- By Redefine12 in forum AWT / SwingReplies: 6Last Post: 03-21-2012, 05:11 PM
- By mhariharasudan in forum AWT / SwingReplies: 5Last Post: 09-28-2011, 06:43 PM
- By PorgrammingNoob117 in forum AWT / SwingReplies: 3Last Post: 05-10-2011, 11:01 PM
- By krimen_sp in forum Advanced JavaReplies: 1Last Post: 04-22-2011, 11:51 PM
- By noobgrammer in forum New To JavaReplies: 1Last Post: 07-20-2010, 02:44 AM