This week's book giveaway is in the Agile forum.
We're giving away four copies of Head First Agile and have Andrew Stellman & Jennifer Greene on-line!
See this thread for details.
Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java KeyStroke KeyEvent for DELETE but what ActionEvent needed?  RSS feed

 
John H Lee
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following code for a JPanel where I want to make a menu bar with a delete option. This action will delete a selected row off a JList. I've built this using the Java Swing tutorials on Oracle's site and using their TransferHandler class, which does CUT, COPY and PASTE.

My current problem is that I must type "SHIFT - DELETE" for the CUT action to execute but I want it to run when pressing "DELETE" by its self. I believe this is dependent on the ACtionEvent. This application will be running on Windows.

Any thoughts please?

Thanks!


 
Rob Camick
Ranch Hand
Posts: 2801
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


My current problem is that I must type "SHIFT - DELETE" for the CUT action to execute but I want it to run when pressing "DELETE" by its self


Don't specify the meta mask as part of the keystroke.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!