File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Right click popup menu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Right click popup menu" Watch "Right click popup menu" New topic

Right click popup menu

Tay Thotheolh
Ranch Hand

Joined: Aug 07, 2008
Posts: 84
Hi. I added a right click popup menu to my codes with the help of Netbeans 6.7.1 to auto generate the codes. It worked on Linux platform ( my development platform is on Linux ). i wanted to test it out on Windows to see how it worked so i deployed it on a win XP Home Edition with the latest Java (Sun) version as of now (I did a check). Somhow, right click does not cause the popup to appear which had worked on other machines i have tested (Linux). I doubt if this is the issue of OS platform since Swing GUI is suppose to be platform independent because it's Java.\

Does anyone have any idea what went wrong ?

Above is a short snapshot of the code.I tried to attach the java file but javaranch system doesn't accept it so I gave it a plain text and also tried a '.txt' but it doesn't accept so below is the entire codes if you want.

Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2451
Your question is about a popup, so all you need is a JFrame with a component and the code for the popup. I'm not going to even bother looking at all that code, since 90% of the code has nothing to do with your described problem.

If you need further help then you need to create a SSCCE (Short, Self Contained, Compilable and Executable, Example Program), that demonstrates the incorrect behaviour.

Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.
santhosh varala kumar

Joined: Nov 05, 2009
Posts: 25
Use JPopupMenu for the component, for which you are interested.
Tay Thotheolh
Ranch Hand

Joined: Aug 07, 2008
Posts: 84
Hi. I did have a JPopupMenu and the program is working totally fine on Linux but when i use it on Windows... why did it not work ? The problem that puzzles me is that it works on Linux but fails to display the popup on Windows. Both are using Java 6 and are the latest updates available. I doubt it's about the codes... I have cross referenced my codes with the codes available on the internet and they are correct supposedly. Why could Linux(Ubuntu) do as what i wanted but not for Windows (XP) ? Both systems are running Sun's JRE.
Tay Thotheolh
Ranch Hand

Joined: Aug 07, 2008
Posts: 84
Here are the codes I used:

Note: The initComponents() are generated by Netbeans IDE which is presumably correct.

The same thing happened... Linux using both OpenJDK and Sun Java's Official VM running on Java 6 could work and display the popup but not on Windows XP running Java 6 (Sun Java).
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
posting 800 lines of code, then not having the decency to post a follow up that you have an answer in the sun forums.

I look forward to ignoring your next problem.
I agree. Here's the link:
subject: Right click popup menu
It's not a secret anymore!