This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Right click popup menu" Watch "Right click popup menu" New topic
Author

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: 2152
    
    7
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
Greenhorn

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Right click popup menu
 
Similar Threads
how will we move from one page to another within the same window in Swing?
Basic GUI problem :(
Pressing a button to open a new window
NullPtrException when reading JTextField
error sql after removing all jdbc connection