 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
blue Guest
|
Posted: Fri Jan 14, 2005 3:45 pm Post subject: Problem with JPopupMenu (I think...) |
|
|
Brief overview:
I have a JTree within an applet.
I have a MouseListener on the JTree to trap a right mouse click and display
a JPopupMenu
...public void mousePressed(MouseEvent e)
{
if (e.isMetaDown())
{
showPopupMenu( e );
return;
}
}
Problem:
We've encountered a problem (inconsistent), where a user will right click on
a "new" node on the tree, and the browser just hangs. The only way to close
the browser is with task manager (I'm running WinXP, IE 6, jdk 1.4.2_04).
The showPopupMenu method is called:
public void showPopupMenu(MouseEvent mouse_event)
{
try
{
// get root node from tree model
SpiderClientNode root_node =
(SpiderClientNode)tree_model.getRoot();
// get the path from the mouse event object (where the user
clicked)
TreePath mouse_click_path = getPathForLocation(mouse_event.getX(),
mouse_event.getY());
// if mouse click path is null, do nothing
if (mouse_click_path != null)
{
System.out.println("have mouse click path, now retrieving the
node at that path");
// get SpiderClientNode from path
SpiderClientNode mouse_click_node =
(SpiderClientNode)mouse_click_path.getLastPathComponent();
// if node is null, do nothing
if (mouse_click_node != null)
{
System.out.println("user clicked on node with product id: " +
mouse_click_node.getProductId());
// get currently selected path
TreePath selected_path = getSelectionPath();
// get selected node from path
SpiderClientNode selected_node =
(SpiderClientNode)selected_path.getLastPathComponent();
// if selected node is different than the mouse click node,
set new selection path
if (selected_node != null && selected_node !=
mouse_click_node)
{
System.out.println("selected node is different than the
mouse click node, setting new selection path");
// call method to set global variable for new path
setSelectionPath(mouse_click_path);
}
// if mouse click node is not the root, display the popup
menu
if (mouse_click_node != root_node)
{
System.out.println("mouse click node != root, showing
menu");
// instantiate popup menu
System.out.println("creating new popup menu");
SpiderTreeRTPopupMenu popup = new
SpiderTreeRTPopupMenu(parent_applet,mouse_click_node);
System.out.println("new menu created, display to user at
location X: " + mouse_event.getX() + " and Y: " + mouse_event.getY());
// show the menu at mouse click location
popup.show( mouse_event.getComponent(),
mouse_event.getX(), mouse_event.getY() );
System.out.println("menu should now be displayed");
}
}
else
{
System.out.println("user did not right click on a node in the
tree");
}
}
else
{
System.out.println("mouse click path is null");
}
}
catch (Exception e)
{
System.out.println("SpiderTreeRT::showPopupMenu(MouseEvent)::Unable
to show popup");
e.printStackTrace();
}
}
I get all System.out's up until the popup.show method is called, then the
browser hangs.
Has anyone encountered such a problem? Any input would be greatly
appreciated.
Thank you,
Frank
|
|
| Back to top |
|
 |
Andrew Thompson Guest
|
|
| Back to top |
|
 |
blue Guest
|
Posted: Wed Jan 19, 2005 1:48 pm Post subject: Re: Problem with JPopupMenu (I think...) |
|
|
Sorry,
Intranet only....
Frank
"Andrew Thompson" <SeeMySites (AT) www (DOT) invalid> wrote
|
|
| Back to top |
|
 |
Andrew Thompson Guest
|
Posted: Thu Jan 20, 2005 8:59 am Post subject: Re: Problem with JPopupMenu (I think...) |
|
|
On Wed, 19 Jan 2005 08:48:04 -0500, blue wrote:
Why? Is it secret?
If there is some compelling reason your applet cannot be shown
to the public, create an SSCCE[1] instead, and please note the
comments on line length.
[1] <http://www.physci.org/codes/sscce.jsp>
--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
|
|
| Back to top |
|
 |
blue Guest
|
Posted: Thu Jan 20, 2005 3:06 pm Post subject: Re: Problem with JPopupMenu (I think...) |
|
|
When dealing with customer data, yes, it becomes "secret". I've set up a
test product which you can access from:
http://elogia-salesdemos.net/cse35/cse
Login with config/config
Select "RACK" under "- Product Configuration" in the "Enterprise Tools"
section on the left.
Once the applet loads, you will see a configuration tree on the left hand
side. A right click on any node other than the root will (should) display
the popup menu with information about that node. Sometimes the menu will
show, other times, the browser will just lock up.
Thanks for you time. I've also tried changing my code so that no components
are instantiated in the listener events, this didn't help either.
Frank
"Andrew Thompson" <SeeMySites (AT) www (DOT) invalid> wrote
|
|
| Back to top |
|
 |
Andrew Thompson Guest
|
Posted: Fri Jan 21, 2005 9:10 am Post subject: Re: Problem with JPopupMenu (I think...) |
|
|
On Thu, 20 Jan 2005 10:06:00 -0500, blue wrote:
Please refrain from top-posting Frank, I find it most confusing.
<http://www.physci.org/codes/javafaq.jsp#netiquette>
See further comments 'in-line with trimming'
| Quote: | "Andrew Thompson" <SeeMySites (AT) www (DOT) invalid> wrote in message
news:173q5a20uxtxv$.lwi7zvib2ug.dlg (AT) 40tude (DOT) net...
On Wed, 19 Jan 2005 08:48:04 -0500, blue wrote:
Intranet only....
...
..create an SSCCE[1]
...
[1] <http://www.physci.org/codes/sscce.jsp
When dealing with customer data, yes, it becomes "secret".
|
Just a point, but since I will be referencing the above-linked
article again, I will point out that the SSCCE document advises
you to replace D/B and I/O related data structures with dummy
information (hard coded if necessary).
...Goood.
| Quote: | Login with config/config
|
Ah, now.. Please read the SSCCE document. This is a problem with
a *Tooltip* fer'chrissake [ ], there is no 'login' required to
replicate that, is there?
BTW - I should point out that some clever person may happen
along who can either guess, or spot, the problem. But if that does
not happen, an SSCCE is the best way to solve the problem.
I suggest you go off and read the SSCCE document carefully and
consider what it says (there is more to it than first appearances
might suggest), then consider whether an SSCCE might be the way
to resolve this technical problem. ...
[ My apologies if you have already read that document, but I
hoped it would make clear that a 'login' should be stripped
from the applet before asking people for help on the code. ]
--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
|
|
| Back to top |
|
 |
blue Guest
|
Posted: Fri Jan 28, 2005 3:56 pm Post subject: Re: Problem with JPopupMenu (I think...) |
|
|
Just an FYI:
The problem turned out to be a conflict between showing the popup menu and
spawning an action thread on node selection. If I simply run the method
calls in the change listener without threading them, all is well.
Thank you for all of your input.
Frank
|
|
| Back to top |
|
 |
Andrew Thompson Guest
|
Posted: Sat Jan 29, 2005 11:57 am Post subject: Re: Problem with JPopupMenu (I think...) |
|
|
On Fri, 28 Jan 2005 10:56:37 -0500, blue wrote:
| Quote: | The problem turned out to be a conflict between showing the popup menu and
spawning an action thread on node selection.
|
Thanks for reporting the problem resolution, and it's solution.
| Quote: | ..If I simply run the method
calls in the change listener without threading them, all is well.
|
Excellent stuff, glad you sorted it.
| Quote: | Thank you for all of your input.
|
You're welcome, always happy to help someone find their own solution. ;-)
--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|