• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Working on a JList and giving it more options?

 
Ben Jass
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys, this is my situation, I have a program that you can input arrays into it. When you input these arrays into a JTextField, it takes the values, puts them in numeric order, and puts in them in a JList.

I'm not very experienced with swing, is there a way I can make it so that if I right click one of the selections inside the array I can give it an option to delete it from the array?

I know how to delete things from an array and all that, I'm just curious how to get my mouse involved so that if I right click on a selection it brings up a drop down menu or something, you know like if you randomly click on your screen, but this one gives you an option to "Delete this value"?

Thanks
~ Benny
 
Rob Camick
Ranch Hand
Posts: 2539
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the JLIst API and follow the link to the section in the Swing tutorial on "How to Use Lists" for a working example that allows you to add/remove items from a JList.
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also the JPopupMenu API, which has a link to the tutorial on How to Use Menus.
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And even more important, BeForthrightWhenCrossPostingToOtherSites
http://www.java-forums.org/awt-swing/37425-removing-values-array-list.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic