Article View: borland.public.jbuilder.java.swing
Article #13115Re: GridControl & JPopup
From: Paul Furbacher
Date: Wed, 23 Sep 1998 00:00
Date: Wed, 23 Sep 1998 00:00
44 lines
2335 bytes
2335 bytes
John Sinues wrote:
>
> Swing popup menus do not appear to correctly display in the JBCL
> GridControl if the gridcontrol has horizontal/vertical scrollbars. The
> popup menu seem to "scroll off the screen".
>
> It appears that in the mouseClicked event that the e.getX() and
> e.getY() methods are not returning relevant values to the displayed
> grid (ie. if you click at grid (12, 3) the returned XY coordinates are
> (415,249-lower right corner) on a 1024x768 display. Then if scroll to
> (15,10) the returned XY coordinates are (1052,303) which is off the
> viewing area of the screen.
>
>[...]
> void gridControl1_mouseClicked(MouseEvent e) {
> if (e.getModifiers() == Event.META_MASK) {
> gridControl1.add(jPopupMenu1);
> jPopupMenu1.show(gridControl1, e.getX(), e.getY());
> }
> System.out.println("x= " + e.getX() + ", y= " + e.getY());
> }
If you track the "e.getX()" and "e.getY()" results, you'll
notice that the value of Y will change as you scroll down.
(The same is true for X if you scroll horizontally.)
Hence, you must calculate an offset based on the topX and topY
values of the grid within the JScrollPane (i.e., GridControl)
and the current origin of the grid.
Here are some offsets to consider:
o offsets of all containers which contain the grid control
-- iterate through the container hierarchy using "getParent()"
and accumulating an container hierarchy offset.
o scrollPosition [gridControl.getScrollPosition()]
When implementing a popup in a TreeControl, I was astonished
to find my popup was still some 20-30 pixels too high. Even
the top-most container had a Y offset.
Good luck.
Paul Furbacher
Technical Details
Message-ID:
<36097129.AA301577@bilbo.bio.purdue.edu>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<36094EFE.BFFCA2B@prc.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,d3bb3d9a4906fe61 X-Google-Attributes: gid111d45,public From: Paul Furbacher <pf@bilbo.bio.purdue.edu> Subject: Re: GridControl & JPopup Date: 1998/09/23 Message-ID: <36097129.AA301577@bilbo.bio.purdue.edu> X-Deja-AN: 394149517 Content-Transfer-Encoding: 7bit References: <36094EFE.BFFCA2B@prc.com> To: John Sinues <sinues_john@prc.com> Content-Type: text/plain; charset=us-ascii Organization: Biological Sciences, Purdue Univ. Mime-Version: 1.0 Reply-To: pf@bilbo.bio.purdue.edu Newsgroups: borland.public.jbuilder.java.swing