AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with JPopupMenu (I think...)

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits
View previous topic :: View next topic  
Author Message
blue
Guest





PostPosted: Fri Jan 14, 2005 3:45 pm    Post subject: Problem with JPopupMenu (I think...) Reply with quote



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





PostPosted: Fri Jan 14, 2005 10:58 pm    Post subject: Re: Problem with JPopupMenu (I think...) Reply with quote



On Fri, 14 Jan 2005 10:45:22 -0500, blue wrote:

Quote:
I have a JTree within an applet.

URL?

--
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





PostPosted: Wed Jan 19, 2005 1:48 pm    Post subject: Re: Problem with JPopupMenu (I think...) Reply with quote



Sorry,

Intranet only....

Frank

"Andrew Thompson" <SeeMySites (AT) www (DOT) invalid> wrote

Quote:
On Fri, 14 Jan 2005 10:45:22 -0500, blue wrote:

I have a JTree within an applet.

URL?

--
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
Andrew Thompson
Guest





PostPosted: Thu Jan 20, 2005 8:59 am    Post subject: Re: Problem with JPopupMenu (I think...) Reply with quote

On Wed, 19 Jan 2005 08:48:04 -0500, blue wrote:

Quote:
Intranet only....

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





PostPosted: Thu Jan 20, 2005 3:06 pm    Post subject: Re: Problem with JPopupMenu (I think...) Reply with quote

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

Quote:
On Wed, 19 Jan 2005 08:48:04 -0500, blue wrote:

Intranet only....

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
Andrew Thompson
Guest





PostPosted: Fri Jan 21, 2005 9:10 am    Post subject: Re: Problem with JPopupMenu (I think...) Reply with quote

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).

Quote:
..I've set up a
test product which you can access from:

http://elogia-salesdemos.net/cse35/cse

...Goood.

Quote:
Login with config/config

Ah, now.. Please read the SSCCE document. This is a problem with
a *Tooltip* fer'chrissake [ Wink ], 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





PostPosted: Fri Jan 28, 2005 3:56 pm    Post subject: Re: Problem with JPopupMenu (I think...) Reply with quote

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





PostPosted: Sat Jan 29, 2005 11:57 am    Post subject: Re: Problem with JPopupMenu (I think...) Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.