🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

GridControl & JPopup

#13112
From: John Sinues
Date: Wed, 23 Sep 1998 00:00
104 lines
3567 bytes
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.

Attached is a small piece of code that exhibits this problem.

We are developing using JBuilder 2.000.174.

--- BEGIN CODE --------

package GridPopuptest;

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import com.sun.java.swing.*;
import borland.jbcl.control.*;

public class Applet1 extends JApplet {
  boolean isStandalone = false;
  GridControl gridControl1 = new GridControl();
  BorderLayout borderLayout1 = new BorderLayout();
  JPopupMenu jPopupMenu1 = new JPopupMenu();
  JMenuItem jMenuItem1 = new JMenuItem();
  JMenuItem jMenuItem2 = new JMenuItem();
  JMenuItem jMenuItem3 = new JMenuItem();

  //Construct the applet

  public Applet1() {
  }
//Initialize the applet

  public void init() {
    try {
    jbInit();
    }
    catch (Exception e) {
    e.printStackTrace();
    }
    // Create and fill a 50 x 50 array
    String[][] s = new String [50][50];
    for (int i = 0; i < 50; i++) {
         for (int j = 0; j < 50; j++)
             s[i][j] =  String.valueOf(i) + "," + String.valueOf(j);
         }

    gridControl1.setItems(s);

  }
  private void jbInit() throws Exception {
    this.setSize(400,300);
    this.getContentPane().setLayout(borderLayout1);
    gridControl1.setItems(new String[][] {{""},});
    gridControl1.setNavigateOnEnter(false);
    gridControl1.setShowPopup(false);
    gridControl1.addMouseListener(new java.awt.event.MouseAdapter() {
      public void mouseClicked(MouseEvent e) {
        gridControl1_mouseClicked(e);
      }
    });
    jPopupMenu1.setLightWeightPopupEnabled(false);
    jPopupMenu1.setInvoker(gridControl1);
    jMenuItem1.setText("jPopuMenu1-1");
    jMenuItem2.setText("jPopuMenu1-2");
    jMenuItem3.setText("jPopuMenu1-3");

    this.getContentPane().add(gridControl1, BorderLayout.CENTER);
    jPopupMenu1.add(jMenuItem1);
    jPopupMenu1.add(jMenuItem2);
    jPopupMenu1.add(jMenuItem3);
  }
//Get Applet information

  public String getAppletInfo() {
    return "Applet Information";
  }
//Get parameter info

  public String[][] getParameterInfo() {
    return null;
  }

  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());
  }

  void gridControl1_actionPerformed(ActionEvent e) {

  }
}

--- END CODE ----------
Technical Details
Message-ID: <36094EFE.BFFCA2B@prc.com>
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,d3bb3d9a4906fe61,start
X-Google-Attributes: gid111d45,public
From: John Sinues <sinues_john@prc.com>
Subject: GridControl & JPopup
Date: 1998/09/23
Message-ID: <36094EFE.BFFCA2B@prc.com>
X-Deja-AN: 394081600
Content-Transfer-Encoding: 7bit
Organization: Another Netscape Collabra Server User
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing