Note that there are some explanatory texts on larger screens.

plurals
  1. POChange table entry on key event
    primarykey
    data
    text
    <p>I have a JTable that starts the editing automatically when pushing a key. The already inputted text will also be deleted, so that if you start typing only your typing gets the current value. That works, but my problem is, that every key starts that editing, like capslock, numlock, esc and stuff like that. How can I exclude all kind of control keys from that editing, without excluding one by one?</p> <p>Here's the code I already have. It's in the Method isCellEditable in the TableCellEditor related to the table.</p> <pre><code>// It's a keyevent, so check if it's a key that should start editing if (anEvent instanceof KeyEvent) { // Get the events key int keyCode = ((KeyEvent) anEvent).getKeyCode(); char keyChar = ((KeyEvent) anEvent).getKeyChar(); // Convert character to lower case by first creating a string out of it keyChar = ("" + keyChar).toLowerCase().charAt(0); // F2 allowed if (keyCode == KeyEvent.VK_F2) { return true; } // Keycode is unknown so check if we can at least find the keyChar if (keyCode == 0 &amp;&amp; (keyChar == 'ä' || keyChar == 'ö' || keyChar == 'ü')) { resetText = true; return true; } // Control characters disallowed if (keyCode &lt; 32 || keyCode == KeyEvent.VK_WINDOWS || keyCode == KeyEvent.VK_CONTEXT_MENU || keyCode == KeyEvent.VK_SCROLL_LOCK || keyCode == KeyEvent.VK_NUM_LOCK || keyCode == KeyEvent.VK_META || (keyCode &gt;= KeyEvent.VK_F1 &amp;&amp; keyCode &lt;= KeyEvent.VK_F12)) return false; // all other keys are allowed resetText = true; return true; </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload