• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Adding a conditional popup menu to a Jtable using Matisse in Netbeans?

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm trying to add a popup menu to a Jtable such that the menu only shows when a row is selected in the Jtable. Can anyone help me with how to do this,
I'm using the Matisse GUI builder in Netbeans 6.7.1
I can add a popup menu OK but it is possible to pull up the menu even when no table row is selected, this is what I am trying to avoid.

Thanks
Pete
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pete,
Welcome to the Ranch.

How are you showing the popup? Have you used the JCOmponent#setComponentPopupMenu()? If yes, you will need to use mouse listeners and use the JPopupMenu#show() instead, which will be triggered only if any table row(s) is/are selected.
 
Pete Dawson
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply,

Yes the automatically generated code contains

jTable1.setComponentPopupMenu(jPopupMenu1);

So that means I need to back up a step and add the menu programmatically myself? GUI builders are a bit tricky when you can only do part of the job with them!

Pete
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

GUI builders are a bit tricky when you can only do part of the job with them!



Which is why people who want to learn Swing don't use them.
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pete,
To answer your question, yes. You will have to use the mouse listener approach.

I am with Rob here. IDEs which auto generate the code never give you the level of control which hand coding does (as you have found out yourself). Also, Netbeans generated code will not (always) work on other IDEs like say Eclipse.
 
reply
    Bookmark Topic Watch Topic
  • New Topic