Trapping key Event when DELETE is pressed in the JTAble

I want to trap keyEvent when i press DELETE Key in the JTABLE.

Hi,
you could use InputMap and ActionMap, like below:
      // Read the maps
      InputMap inmap = yourTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
      ActionMap actmap = yourTable.getActionMap();
      // Build the action
      Action yourAction = new AbstractAction() {
         public void actionPerformed(ActionEvent e) {
            //... your event code here...
      // Map DELETE key to the action
      inmap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE), "Delete");
      actmap.put("Delete", yourAction);I didn't try this with a JTable, but it works perfectly with JList and JTree...
Hope this will help,
Regards.

Similar Messages

  • No key event when compose keys are pressed

    I am supporting a legacy application for Sabre which maps some of the keys differently. For example, on a French keyboard the Compose key which is used to put a ^ on top of the vowel characters is to be remapped to produce a special character called a "Change Character" that has a special use for reservation agents that use Sabre
    The problem is, the first time you press the ^ compose key there is no key event apparently because the VM figures it doesn't yet know what key to report, it is expecting you to press a character such as 'o' and then you get an 'o' with a '^' on top of it.
    If you press the ^ compose key a second time, you get the following key events:
    keyPressed
    keyTyped
    keyTyped
    keyReleased
    On the screen you will see two ^ characters appear. Currently I remap the ^ character to the "Change Character", and I suppress the second keyTyped event so that I only get one character. The problem is that the user ends up having to press the key twice to get one "Change Character."
    I have no fix for this problem because there is no key event produced when they press the ^ compose key the first time.
    By the way, this behavior appears to have been introduced with jdk 1.3. The older jdk did produce a key event the first time you pressed the compose key. I would expect that this behavior was considered to be a bug and was fixed in jdk 1.3.
    Is there some other way to detect when the user presses a compose key? If not, is it possible for future jdk releases to report a keyPressed event when a compose key is pressed? This event would not cause a character to appear on the screen, but would allow programs to detect when the compose key is pressed.
    There is already a key on the French keyboard that behaves this way. It is the key to the left of the '1' key and it has the pipe symbol on it. If you press Shift plus this pipe key, no character is produces but a keyPressed event with a keycode of 222 is produced. I merely point this out to show that there is a way to report key events whithout producing output on the screen.
    Thanks, Brian Bruderer

    I don't know if this actually helps, but it seems that you can bind an Action to a dead key like the circumflex of the French keyboard
    Keymap keymap = textPane.addKeymap("MyEmacsBindings", textPane.getKeymap());
    Action action = getActionByName(DefaultEditorKit.beginAction );
    KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_DEAD_CIRCUMFLEX);
    keymap.addActionForKeyStroke(key, action);I saw this on a Swing tutorial and modified it slightly. Have a look at it :
    http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html
    Chris

  • When will iPhone have a "range option" when deleting recents calls. The current, one call at time or all, options are not practical.

    When will iPhone offer an "range" option when deleting recent calls. The currents options of "one" or "all" are not practical.

    Really Chris? Yes Really!!!
    You've never used Excel? You can delete multiple rows or columns with ease.
    Yahoo mail gives you an option, by checking a box preceeding the messages, to move or cancel selected (range) messages in mass. I use it daily.
    Outlook and Outlook Express both give you the option to cancel a range of messages, highlight the first message, shift key held, highlight the last message, delete.
    I guess I did not consider browsers or games as stored data when I made the comment

  • Hello, Honestly I just updated my 4s and my iPad 3 to iOS 6 and when try to press on the Music app or the iTunes app it says "cannot connect to iTunes Store" Could you please help me with this thank you so much, Charbel from Lebanon

    Hello, Honestly I just updated my 4s and my iPad 3 to iOS 6 and when try to press on the Music app or the iTunes app it says "cannot connect to iTunes Store" Could you please help me with this thank you so much, Charbel from Lebanon

    See these previous discussions help.
    App Store Updates (but only Updates)...: Apple Support Communities
    Apps suddenly don't update: Apple Support Communities

  • When deleting emails i get the following error message at times ...The IMAP command "UID COPY" (to Deleted) failed for the mailbox "INBOX" with server error: Error 9. Server error. Please try again later..

    When deleting emails i get the following error message at times ...The IMAP command “UID COPY” (to Deleted) failed for the mailbox “INBOX” with server error: Error 9. Server error. Please try again later..

    Please complete or update your system profile so the users here can properly help you.
    Which email client are you using?

  • HT2240 I purchased a QT Pro Reg. Code Key. When I install it in the QT Preferences Panel, I get an: "Invalid Registration" note at the bottom, next to the "Buy QuickTime Pro" button to the right. Both on a desk top and a laptop. Win 7, QT version 7.7.1. N

    I purchased a QT Pro Reg. Code Key. When I install it in the QT Preferences Panel, I get an: "Invalid Registration" note at the bottom, next to the "Buy QuickTime Pro" button to the right. Both on a desk top and a laptop. Win 7, QT version 7.7.1. No joy! I've been on the phone with Apple for a little more than an hour, so far. They have my money. anyone have any Ideas? Just kiss the thirty bucks goodbye?

    You,Sir, are "The Man"! I followed the instructions and - viola - Joy in Mudville. Thank you, keep up the great work. Even the "Apple" people don't seem to know this. I was on the phone with them, passed from one to another, for over an hour. While waiting I stumbled on your advise and I was made free! If they ask you, charge them a mint for the information. You Sir have gone where no Apple has gone before.

  • Unable to find Key Events when there are multiple Commands

    Hi,
    I've developed a simple J2ME Appln containing 3 commands
    for ex- Exit,Help and Info(all with same priority).
    As there are 3 commands, Exit command is present at the left and the other two namely Help and Info have been listed under Menu and this Menu command is presented at the right.
    My MIDlet class has extened MIDlet and implemented CommandListener. Using CommandAction(), I'm able to generate action for Command press and i've also created a nested class which extends Canvas so, using keyPressed and keyReleased, I'm able to find the Key Press Events.
    Now, my appln needs to find just the key press events. After i press the Menu command, the two commands namely Help and Info are listed. In tht screen, I need to find out whether any other key events are being generated but my keyPressed and keyReleased are not being called.
    Please provide me solution ASAP.

    I'm going to make a few assumptions:
    1. The menu you're describing is the automatically generated one caused by having more than two commands.
    2. The subclass of Canvas is the currently active Displayable (otherwise you won't get any key events at all).
    If this is the case (and someone correct me if I'm wrong), key events are being handled by the phone's subsystem to drive the menu, which means there's no way to get them. The way I've approached this kind of problem is to create my own menu painting and handling code and incorporated it into the Canvas. Then, make one Command called 'Menu' and have it invoke your custom menu code.
    I realise this isn't an ideal solution, but it's something.

  • F1 Key seems to be constantly pressed all the time but it is not the key

    My Envy DV7 was getting too hot so I decided to open it up and clean the fan myself ( After I cleaned the fan, It was very difficult for me to close it back, because the keyboard on this Pc is attached to the whole top so I had to take it to a laptop shop, so they can close it for me) When I finally got to close it the F1 key seemed to be pressed all the time when it is actually not, the thing is that it only happens when it first boots up after a while the laptop works just fine.

    It should only scan when you select the AirPort drop down menu. Anytime you do this it is going to scan for wireless networks in case you want to connect to one that has come online or gone offline since the last scan. That doesn't mean it is always scanning, it just means it is scanning anytime you use the drop down menu. This is normal.

  • What happened to the dust cloud when deleting an app on the dock?

    I'm not sure if the little dust cloud animation was deleted when removing an item from the dock.  It still makes the sound though?!?
    I think I'm alone in thinking that 'design' (and personality) is leaving the OS as it's a far cry from the Aqua buttons but it seems the pendulum may have swung too far as with the blank white flat design, things just seem to run together.
    Sigh.

    I don't mind seeing stuff like the leatherette appearance going but getting rid of the 'puff of smoke' is getting rid of the OSX personality! 
    Thank goodness they didn't get rid of the 'genie' effect when minimizing/maximizing windows or there'd be a revolt!
    Sigh, it'll probably go in the next update.

  • Hibernate: how to null out foreign key references when deleting an entity?

    We use Spring/Hibernate3 in our app, and ran into kind of a bummer of a problem. We have a relationship that is many-to-one (e.g. Student -> School). This is represented by a schoolId on the Student table. When we delete the school through the Hibernate layer, we are immediately receiving foreign key constraints because Hibernate does not null out the Students' schoolId columns where applicable.
    What we'd like to see happen is something like this:
    1. SchoolDAO.delete(id)
    Hibernate: UPDATE Student set schoolId = NULL where schoolId = ?
    Hibernate: DELETE from School where id = ?
    But what we're actually seeing is:
    1. SchoolDAO.delete(id)
    Hibernate: DELETE from School where id = ?
    And hence the foreign key constraints.
    Was wondering if someone else here has run into this. Someone on the Hibernate forums suggested using an Interceptor, but the Hibernate3 interceptors don't give us access to the Session to allow us to do a bulk update to null out these references. Apparently the interceptor javadoc says that the interceptor is basically there to change properties on the object in question and should not involve the session at all.
    We then looked at implementing an Event, and that worked, but was not called for every cascade deleted event. We have a lot of cascade activity in our database, so that was a little disappointing.
    We had briefly considered manually nulling out that FK in the DAO itself, but that would not work with the large amount of Hibernate driven cascade deletion that goes on in our app (Hibernate does not call our DAO every time it cascade deletes an entity).
    Would greatly appreciate any pointers on this subject. We're hoping that others have run into this as well.
    thanks.

    I'm not sure why you'd expect that given that there's
    not really an equivalent object oriented operation -
    if you want to relinquish the object in the OO scheme
    of things you have to null all the references to it;
    you can't just say "make everything that points to
    this object null".I can field that question. We came from EJB 2.x where in the event that you deleted a School entity bean using ejbRemove() you would see the following queries generated:
    UPDATE Student set schoolId = NULL where schoolId = ?
    DELETE from School where id = ?
    Basically, it would manage the relationship for you. I know it's a completely different system but we were a little surprised to learn that Hibernate did not do this on its own as well.

  • Can't delete a contact in Contacts. It only beeps when 'delete' is pressed.

    Since setting my contacts to use iCloud to sync with my iPad2 Contacts won't let me delete any contact. When I press 'delete' (on the MacBook Pro) it just beeps at me. I tried turning off/on iCloud, but no change. I see "On My Mac" and "iCloud" contact groups with the same problem on both.
    JA

    Same problem here. I have inactivated iCloud contacts, eliminated google contacts, and have only contacts associated with an Exchange account.  From Contacts on my macbook running Mavericks, whether I select one contact or select all, the option to delete is grey, and using the delete key results in a beep.
    I can delete individual cards from iPhone contacts, however.  Exchange directory is also only available from iPhone.

  • Do not get key events when HContainer object is added to HScene

    Experts,
    Please help, I am missing something simple.
    I am creating an container (mCurrentContainer) with some buttons in them as follows,
              mRecListButton = new HTextButton("List", curX, curY);
              add(mRecListButton);
              // Setup a recording
              curY += V3Button.mHeight + gap;
              mRecButton = new HTextButton("Record", curX , curY);
              add(mRecButton);
              // Shows the list of scheduled recordings
              curY += V3Button.mHeight + gap;
              mScheduleRecButton = new HTextButton("Schedule", curX , curY);
              add(mScheduleRecButton);
              // Shows the list of Series Recordings
              curY += V3Button.mHeight + gap;
              mSeriesRecButton = new HTextButton("Series", curX, curY);
              add(mSeriesRecButton);
              mCurrentSelectedButton = LISTVALUE;
              mRecListButton.setFocus();
    Then I am creating a scene,
              HSceneFactory factory = HSceneFactory.getInstance();
              HSceneTemplate sceneTemplate = new HSceneTemplate();
              sceneTemplate.setPreference(HSceneTemplate.
                             SCENE_PIXEL_DIMENSION,
                             new Dimension(640, 400),
                             HSceneTemplate.REQUIRED);
              sceneTemplate.setPreference(HSceneTemplate.
                             SCENE_SCREEN_LOCATION,
                             new HScreenPoint((float)0,(float)0),
                             HSceneTemplate.REQUIRED);
              mScene = factory.getBestScene(sceneTemplate);
              mScene.requestFocus();
              mScene.addFocusListener(this);
    Then, I add the above container to the mscene as follows,
    mCurrentContainer = myContainer;
    mScene.add(mCurrentContainer); // Keys Presses do not work if left uncommented
    mScene.setVisible(true);
    mScene.requestFocus();
    mScene.addKeyListener( mCurrentContainer);
    mCurrentContainer.setVisible(true);
    mCurrentContainer.requestFocus();
    I see the buttons correctly and the "List" button is highlighted correctly. However, I do not get any key presses.
    Now, if I comment out "mScene.add()" as follows,
    mCurrentContainer = myContainer;
    // mScene.add(mCurrentContainer); // Now the key presses works correctly.
    mScene.setVisible(true);
    mScene.requestFocus();
    mScene.addKeyListener( mCurrentContainer);
    mCurrentContainer.setVisible(true);
    mCurrentContainer.requestFocus();
    The key presses works correctly. However, the buttons are not displayed now.
    What am I missing?
    Thanks!

    I have not tried the above suggestions but the problem is solved. The issue was - I had the requirement of creating a a default child record when the parent record is created. I was creating the child record using insert statement in Prepared Statement in the doDML of parent EOImpl. So it is not creating a row in the EO and when I add the second record through the application and save, the getRowCount returns 1 which is new record that created through application. Sorry for not providing this info earlier and Thank You all.
    Regards, Pradeep

  • Trigger events when delete/modify certain folder in KM

    Dear Experts,
    I have a requirement like when certain folder is being deleted/modified I want an event need to be trigger, such that I will put some checks before these commands performed.
    Basically my requirement is, I have a custom iViews created and are using custom tables in databse.  When I create the folders in KM, I am creating/maintaining these folder reference in my custom tablese using my custom iView.
    Now when I delete the folder from KM, I want to show some warning message before deleting the folder and simulatenously these folder references should also be deleted from my custom tables.
    Please give me suggestions how to acheive the above scenario.
    Thanks in Advance,
    Chinna.

    Hi Yogalakshmi,
    I have created a Repository service using the document provided. I have registered the pre_delete_template  event using the below code         
    unregister(this,ResourceEvent.PRE_DELETE_TEMPLATE);
    I am printing some trace when this event occurs. Logs is being displayed after the folder gets deleted.
    Can you please provide me some code snippet for register predelete event, and on attempting to delete I would like to pop up a window with warning/confirmation message (confirmation popup window). Based on the confirmation from the popup window -- Ok/Cancel, I would like to perform few operations.
    I don't find any documents on Repository Services.
    Could you please provide me code/documents that fulfills my requirement.
    Thanks
    Chinna.

  • Impact on Registered Events when delete node

    Currently I have a node which has more than one database and also has many events registered against multiple database.
    Due to Agent out of sync error I am currently getting, I have to delete the node and rediscover it. If I do it then I need to find out what would happen to all of the registered events against the databases of this node. Do I have to create and registered all those events again.
    Let me know if anybody has answer to this.
    Thanks.
    CHetan

    It is completely absurd that the Calendar changes times when traveling to a different time zone. It's a safe bet to assume that many Blackberry user's are business people. Surely if Blackberry was serious about keeping it's users, it could design software to keep the calendar times as they should be while still updating to the new time zone.
    After all, if I make a 10:00 appointment for when I will be in AZ (even though I'm on the East coast), the appointment is going to be at 10:00, and should not show as 7:00 or 8:00 (depending on the time of year) when I arrive there and change time zones. For flights, I input the correct times in the calendar, and repeat5 the times in "Notes" so that I will have the correct flight times regardless of the time zone change. Is is a difficult thing to do--of course not. Should I have to when the phone runs several hundred dollars--of course not!
    It seems that RIM's OS has many faults which are equally frustrating, and it chooses not to address them.
    Unless RIM gets it's act together, this will most likely be the last Blackberry I will own.
    Too bad--it could be a great tool!

  • SBWP - When delete items in Inbox the error is coming - Lock Entries (SM12)

    Hi Friends,
    Whenever delete workflow items from Inbox (txn : SBWP), I am getting the below error.
    Requested object is currently blocked by user <XXXXX>
    Diagnosis :
    No lock can be granted by calling a function module, as enqueue another SAP transaction keeps blocking concerned.
    Technical: C_ENQUEUE routine provides the following return codes:
    COLLISION_OBJECT = EMMARAE
    COLLISION_UNAME = CEMCONC
    System activity
    The enqueue function module triggers the exception. If this exception was not intercepted by the application program, the SAP transaction is automatically interrupted.
    Procedure
    Check the table blocking the user or transaction that maintains the requested block (Tools -> Administration ==> Monitors -> Entries blocking). Contact this user if necessary.
    After this error, the item is deleted from the inbox. Then, when I go and check in SM12, there are 3 entries are created : 2 entries with Lock Mode as 'S' and one entry with Lock Mode 'E' in MARA table.
    After refresh in RS12/SM12 tcodes, these 3 entries has gone.
    Friends, can you kindly clarify why the above error message is coming while delete ? How to avoid this ?
    Kind regards,
    Jegathees P.

    An Z indexes created for the table CDHDR (Followed the note 150925)

Maybe you are looking for