Default behaviour of the Escape key while editing a cell in JTable??

Hi all,
i have a Jtable which get its data from an own model object which extends DefaultTableModel.
If i overwrite the isCellEditable(row, col) method within the tablemodel object and set a specific column to editable, then i notice while editing a cell in that column that the default behaviour of the Escape key is that independet from what you have entered before in to the cell the editing stops and the cell gets the value it had before editing.
This is the case for me even if i apply a custom editor to a column (one that extends DefaultCellEditor). It is just a JTextField that limits the number of digits a user can enter. Everything works fine. If the user edits the cell and presses ENTER or the "down arrow key" i can check what he has entered with the help of the getCellEditorValue() method. But if the user hits the ESC key after editing a cell this method is not invoked!!!
My question is :
is there any way to detect that the user cancels editing with the ESC-key.
this is very important for me because if the user goes editing the cell i lock the related record in the database, if i cannot detect this it is locked till the application terminates.
Thanks for any help in advance

I try override the JTable editingCanceled() ==> does not work.
I try the addCellEditorListener( CellEditorListener l ) ==> does not work.
Finally, I try the addKeyListener ==> it works.
Here is a quick demo. program:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import javax.swing.table.*;
public class Test {
public static void main(String[] args){
JFrame f = new JFrame();
String[] colName = {"a", "b"};
String[][] rowData = {{"1", "2"}, {"3", "4"}};
JTable table = new JTable(rowData, colName);
JTextField t = new JTextField(10);
t.setBackground(Color.red);
t.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
// do what ever you want ex. un-lock table
System.out.println("ESCAPE");
DefaultCellEditor editor = new DefaultCellEditor(t);
TableColumnModel colModel = table.getColumnModel();
for (int i = colModel.getColumnCount()-1; i >= 0; i--) {
colModel.getColumn(i).setCellEditor(editor);
f.setContentPane(new JScrollPane(table));
f.pack();
f.setVisible(true);

Similar Messages

  • Bug: problems with the Escape key

    Hi all,
    In an attempt to get around real estate problems, I set my Dell 24" monitor in portrait mode. Logic 8 behaves as it should most of the time. However, there appears to be a problem with the Escape key. Most of the time, the Tools menu doesn't appear until you mouse out of the editing areas (eg into the menu area above the piano roll).
    Clearly, Logic should just take its resolution and screen dimensions from the OS but there appears to be a problem in extreme portrait mode.
    I'll report this but wanted to check that I'm not being an absolute and total plonker first. Anybody confirm this behaviour?
    Thanks!
    Pete

    that sounds like a memory issue. have you tried reorganizing memory?

  • When I hit the escape key to close out the open file dialog box, firefox hangs or crashes.

    When I open the "open file" dialog box using the ctrl+O and then hit the escape key to exit the box, I get an error message which I'm not able to paste here.
    it says something about a runtime problem and if I try the same thing again to reproduce the problem, it will sometimes just hang and windows vista will tell me the program is not responding.
    I've checked to see if there are any crash IDs but none were found for this time frame.
    I have even disabled all add ons.
    I'm currently using vista 64 bit edition and Firefox 6, beta edition.

    Hi,
    Please also try right-clicking on the link corresponding to the language version and '''Save Target As''' to save the Firefox installer. If the problem persists, posting [http://answers.microsoft.com/ here] would also be helpful.
    [https://www.mozilla.org/en-US/firefox/all.html Firefox Latest]

  • Using the Escape key in simulations and assessments

    I have recently recorded a simulation/assessment that needs to use the Escape key to close a pop-up window and returns to the main application window. The recording has not been an issue; however, using Escape with failure messages is proving to be tricky.  Here's what I have discovered while resording my sim/assess, along with my questions:
    When I press Escape, Captivate captures this keystroke as a shortcut attached to a Click Box. This works on the assessment side, but fails to produce a failure message on the assessment side when the user does not press the Escape key.
    I need to produce a failure message when the user  does not press Escape.
    Can I storethe unicode value of Escape in a TEB variable and then use an if . . . else statement to either advance to the next slide (success action) or produce a caption that mimics a failure caption?  If so, how would I write this item?
    Could I use a Loss of focus trigger instead?
    Does Captivate have a variable that records a unicode value (Something like CPKeyPressedValue"?
    Are there any other alternatives?

    In the case of buttons and clickbox objects, where clicking is allowed, the failure is normally registered when the user CLICKS OUTSIDE the button or click box.  The evaluation of Success/Fail happens on the click.
    In the case of a Text Entry Box, the interactivity is all about what the user enters into the text field and whether or not it is correct/incorrect when compared to approved answer text.  The main purpose of the TEB object is not centered on the clicking of the button that accompanies the text field.  The button just provides a way to trigger the Success/Failure evaluation of the user interaction with the text field.
    Since you have deselected Allow Mouse Click for your click box, you've effectively made it mandatory to use keystrokes to trigger the Success/Failure evaluation of the object. So clicking outside the box is no longer going to do anything because Allow Mouse Click is off.  You'll get a failure message on this click box now for many (but not all) keystrokes that are not the one assigned.
    By the way, using the Escape key as a keystroke if you Preview the project in Captivate just shuts down the preview (as you've probably already found out).

  • How can I get the escape key to work again?

    I've used "esc" to get out of VI's insert mode for 40 years. I am not going to relearn that keystroke as "ctl-esc", period. Even if I were to do that, then I'd be typing ctl-esc on other platforms where it would not work because I have to type "esc" alone. If there is a way to fix in in System Preferences->keyboard, I cannot find it. If there is not, then it is completely 100% brain-dead wrong. I hope that's not the case.  So there is definitely a bug:
    The key-up event on the escape key does not cause the escape key code to be delivered to the active window when no other key is pressed, or
    The UI is sufficiently obtuse that the cause of the suppression cannot readily be found.
    I do hope it is merely the latter because I am compelled to use Outlook and Outlook does not work properly under OS/X 10.6.  (Our Exchange Server is rigged to only allow Outlook clients to send email outside of the company.)
    Thank you.

    The answer is:  The bug is in the UI.  Speech recognition was enabled, by default it uses the bare escape key as a "mic on" indicator, and it does not leave any trace in the keybord configuration.  So that is the bug.  It needs to leave a trace there, a la: "X Listen-for-voice-command  ^" under Mission Control.

  • P35 Neo Combo behaves as though the escape key is being held down

    When I try to boot my computer, after it gives the initial few beeps it begins to emit a rapid clicking/beeping sound, which I recognize as the "keyboard buffer full" beep that you get when you hold down a key.  As the computer goes through its POST, it becomes apparent that the computer is acting like the escape key is held down.  This doesn't go away even after the OS comes up (I use Ubuntu Linux) and it prevents me from being able to use my computer. 
    I tried loading the default bios settings (which is hard when the BIOS keeps asking you if you want to discard changes and reboot the computer).  I have tried clearing the CMOS.  None of this has worked.
    I have tested the motherboard with several known-working USB and PS/2 keyboards, and the behavior remains.
    This happened once before, and I had to RMA the motherboard.  This is my work computer and I can't afford to wait 2 weeks for it to be fixed, especially if it's going to break again.  If anyone has any suggestions or has encountered this problem before, I would appreciate your help.

    Quote from: Frankenputer on 07-August-08, 02:58:21
    You are basing an opinion about a company from one board? All manufacturers, yes, even Intel, has sold a board that had to have an RMA.  Many times it's a user error rather than the board, but also it's boards that are defective. Basing an opinion based on the experience with one board is not a sound strategy. 
    False.  I've had a variety of bad experiences with MSI products.  Out of 4 MSI products I've bought and used over the past 2 years, all but 1 have needed repair or replacement.  The one good item is a video card.
    Quote from: Frankenputer on 07-August-08, 02:58:21
    In the USA, where I am, MSI MOBOs carry a 3 year warranty(as do VGAs)). So, your statement that your new board has a 3 year warranty which reads as implying that the MSI one does not is false.
    http://www.msicomputer.com/support/sup_genwar.asp
    The MSI warranty only covers labor for up to 2 years.  The Intel warranty maintains the same terms for all 3 years.
    Quote from: Frankenputer on 07-August-08, 02:58:21
    Your statements after "I'm going to RMA this MSI unit" are unnecessary and bashing. There's no need to bash.
    It's not bashing, it's a fact.  It's not unnecessary, it's cautionary.
    This motherboard has failed in this manner twice now.  This failure makes it totally unusable, and causes a severe disruption in my productivity.  As a software developer, I need my computer to work for more than 4 weeks at a time.  In addition, the network chipset failed a few weeks ago and I've been using a 3com card since.
    The last time I RMAd this unit for this same error, it was returned in working order but with no indication of what had gone wrong.  MSI has arranged their company to discourage customer interaction on any meaningful level, so there's no way for me to find out from MSI what they did to fix my board so that I could conceivably avoid another 2-week RMA ordeal.
    If you want a cheap motherboard for a non-critical application, MSI is probably fine.  For a mission-critical workstation, look elsewhere.

  • I need to re-download Lion and install it. Holding the Option key while clicking on "purchases" does not work.

    I need to re-download Lion and install it, after re-formatting my hard-drive to "journaled" as requested. Holding the Option key while clicking on "purchases" does not work.

    Thanks Smokemonster. I found that the Lion install app was in in my applications folder already. Worked fine.

  • Exiting programs using the escape key

    My team and I are design games for autistic children. One of the problems we are having is that we do not know how to quit the application using the escape key. Our team would really appreciate it if you could tell us how this is done.

    Quick example:
    import java.awt.event.*;
    import javax.swing.*;
    public class ExitOnEscape extends JFrame
        public ExitOnEscape()
            setSize(300, 300);
            addKeyListener(new KeyAdapter()
                public void keyPressed(KeyEvent e)
                    int key = e.getKeyCode();
                    if(key == KeyEvent.VK_ESCAPE)
                        System.exit(0);
            setVisible(true);
        public static void main(String[] args)
            new ExitOnEscape();
    }

  • Why can't I close a message once I've read it using the Escape key anymore

    Until recently I have been able to close a message, once read, with the ESCAPE key but this does not seem to work any more.
    Any thoughts on how to fix this?
    WIN7 professional
    Thunderbird 24.6.0
    Thanks
    Geoff

    '''Ctrl + W''' are the keys to close an open tab.
    There is an addon which uses Esc key.
    * https://addons.mozilla.org/en-us/thunderbird/addon/close-tab-on-esc/

  • On iOS 5 for iPad, is there a home button key on the Apple Bluetooth Keyboard that will allow you to go to the home screen or multitask? Perhaps by pressing the escape key or something?

    On iOS 5 for iPad, is there a home button key on the Apple Bluetooth Keyboard that will allow you to go to the home screen or multitask? Perhaps by pressing the escape key or something?

    Sorry, but no one who would know can discuss unreleased software such as iOS 5 in these forums. We'll have to wait, probably for the official release, before such details will be known.
    Regards.

  • How do I get JWindow to respond to the escape key

    Hi,
    I am using JWindow to display an animation program and I want the user to press the "escape" key to end the program. But the program is not responding to any key events. Please help. Below is the code. Thanx.
    public Class DrawPolygons extends JWindow implements KeyListener()
    public void keyPressed(KeyEvent e)
    if(e.getKeyCode() == e.VK_ESCAPE)
    System.exit(0);
    public void keyTyped(KeyEvent e){}
    public void keyReleased(KeyEvent e){}

    My program uses the "Random class" to obtain points to draw polygons. At the beginning of the program I use JOptionPane to obtain the seed to generate the random numbers.
    If I press the "esc" key when the JOptionPane pops-up, the program ends but if I press the key when the polygons are being drawn, the program doesn't end. I am wondering, does it have to do with JWindow, or J2SDK_1.4.01 or could it be because I am using a timer that paints the shapes at a certain time interval? I don't understand. I will appreciate your suggestions, Takis. Thanx.
    Bemmah

  • In the previous version, the menu table in table options, there is an option that gives me the option: the Return key moves to next cell. I do not see this option in the new number. can you help me please?

    in the previous version  of Number, the menu table in table options, there is an option that gives me the option: the Return key moves to next cell. I do not see this option in the new number. can you help me please?

    Hi silvano,
    If you use a regular pattern when entering values, press enter (return) after entering the last value in a row. That will take you to the first Body Cell of the next row.
    Start in Cell B2
    1 Tab 2 Tab 3 Enter
    4 Tab 5 Tab 6 Enter
    7 Tab 8 Tab 9 Enter
    Now you are ready to type into B5 .
    Another way that some people find easier is to enter one column at a time
    Start at B2
    1 enter
    4 enter
    7 enter
    etc.
    Now start with C2.
    Use whatever suits your work flow.
    Regards,
    Ian.

  • On OS X Lion Mountain, how can I get the escape key to work?

    While typing i accidentally disabled the f keys (f1-f10) on the first row and the esc key. After trying to find a solution i manage to enable he f keys but works only after typing the fn key with an f key. The esc key still doesnt work. Can someone helpe me

    Disable the feature in System Preferences.
    http://support.apple.com/kb/HT3399

  • Using the Tilde key while rotating a line is not working?

    I'm trying to make a tilde effect (not sure what it is called?) by holding down the tilde key (above the tab key on my Macbook Pro) while a straight line is selected, though nothing happens when I do this and try to drag the line in a circle to create the effect.
    Anyone have any ideas of what I might be doing wrong?
    Thanks.

    Maybe you've figured this out by now, or gotten the answer elsewhere? The "tilde effect" only works as you are creating the shape, not on an existing shape you've selected.
    Peter

  • Re:Automatic picking up the reconcilliation Key while doing EASIBI

    Dear Team,
    When ever we are doing EASIBI System is not giving the reconcilliation key automatically.We have to give mannually.Please let us know any configuration setting available to get automatically.Thanks for the consideration.
    Regards,
    Suma.

    Hi Suma,
    Please check the configuration for Default values at
    Path - SPRO -> Financial Accounting -> Contract Account Receivable and Payable -> Basic Functions -> Postings and Documents ->  Document -> Define Default values -> Maintain Rules for Reconciliation key default values.
    Please check if the appropriate reconciliation group is assigned to the User ID correctly. If not add the entry here.
    Hope this solves your problem!!
    Regards,
    Rajesh Popat

Maybe you are looking for

  • Hooking a new Mac mini onto my iMac

    Hi there kind people! i'm pretty sure there are several discussions out there considering the possibility to hook a new Mac mini on to iMacs. However mine is pretty specific, so I'd though to give it a go and just spit out! I'm considering buying a n

  • Search bar in contacts is a mystery

    I cannot figure out how the search bar is set up for contacts. Sometimes it will jump up there so you can search and others it will just at the last location- Why did apple NOT make it so it is always visible no matter where you are within your conta

  • Is Adobe DPS available for Android phone?

    hi~ is Adobe DPS available for Android phone? The app is not founded in googleplay..

  • Report Designer : merging cells

    Hi, I have a report with a block of information  and after that block -lower on the same page- the results. So in fact it looks like a 3.5 BEx query result in Excell with a navigation block at the top of the page and the results below that navigation

  • Macro at customer group level

    I have question regarding a macro We are doing Forecast at Product level, So the fcst is diaggreating at sold to party, ship to party, region, sub producgts, and customer groups, Now some of the custtomer group level we dont want to see the fcst. now