🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #8268

JScrollPane & mouse events

#8268
From: natas
Date: Mon, 09 Oct 2000 00:00
40 lines
1758 bytes
Hello,

I've noticed some curious behavior with a JScrollPane component in my
program, and I hope someone can help me understand it.

I have a custom class, "MyScrollableComponent", which extends JComponent,
and implements Scrollable, MouseListener, and MouseMotionListener.  My
intent is to contain a BufferedImage within this class, load in a jpeg, and
then add it (an instance of MyScrollableComponent) to the viewport of a
JScrollPane.  It all works fine, but listening for mouse motion events is a
little strange.

If I do this, e.g., in the constructor of my JFrame class (which contains
the JScrollPane):

...
myScrollPane.setViewportView(myScrollableComponent);
myScrollPane.addMouseMotionListener(myScrollableComponent);
...

Then the mouseMoved() function is called in myScrollableComponent - UNTIL I
load an image into myScrollableComponent.


However, if instead I add myScrollableComponent as a mouse motion listener
to ITSELF, e.g., in the constructor of myScrollableComponent,

....
addMouseMotionListener(this);
....


Then the opposite happens.  I get no mouse activity until I load an image.

Can someone help me understand this interesting behavior of JScrollPane?

Thanks.

--
Please post replies back to  the newsgroup.
Technical Details
Message-ID: <39e29b72$1_1@dnews>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,202852018e6f96f9,start
X-Google-Attributes: gid111d45,public
From: "natas" <cubicle666@hell.com>
Subject: JScrollPane & mouse events
Date: 2000/10/09
Message-ID: <39e29b72$1_1@dnews>
X-Deja-AN: 679591558
X-Trace: 9 Oct 2000 21:30:42 -0800, 207.71.218.242
X-MSMail-Priority: Normal
X-Priority: 3
Newsgroups: borland.public.jbuilder.java.swing
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400