{"record":{"id":"a3ce28e078c83b54","repo":"Konloch/bytecode-viewer","slug":"only-single-character-allowed","errorCode":null,"errorMessage":"Only single character allowed","messagePattern":"Only single character allowed","errorType":"validation","errorClass":"InputMismatchException","httpStatus":null,"severity":"info","filePath":"src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/ValuesPanel.java","lineNumber":606,"sourceCode":"            {\n                showException(ex);\n            }\n        }\n    }//GEN-LAST:event_doubleTextFieldKeyReleased\n\n    private void characterTextFieldKeyReleased(java.awt.event.KeyEvent evt)\n    {//GEN-FIRST:event_characterTextFieldKeyReleased\n        if (evt.getKeyCode() == KeyEvent.VK_ENTER && isEditable())\n        {\n            try\n            {\n                String characterText = characterTextField.getText();\n\n                if (characterText.length() == 0)\n                    throw new InputMismatchException(\"Empty value not valid\");\n\n                if (characterText.length() > 1)\n                    throw new InputMismatchException(\"Only single character allowed\");\n\n                byte[] bytes = characterText.getBytes(codeArea.getCharset());\n                System.arraycopy(bytes, 0, valuesCache, 0, bytes.length);\n\n                modifyValues(bytes.length);\n                updateValues();\n            }\n            catch (InputMismatchException ex)\n            {\n                showException(ex);\n            }\n        }\n    }//GEN-LAST:event_characterTextFieldKeyReleased\n\n    private void stringTextFieldKeyReleased(java.awt.event.KeyEvent evt)\n    {//GEN-FIRST:event_stringTextFieldKeyReleased\n        if (evt.getKeyCode() == KeyEvent.VK_ENTER && isEditable())\n        {","sourceCodeStart":588,"sourceCodeEnd":624,"githubUrl":"https://github.com/Konloch/bytecode-viewer/blob/31430e0033fa220db566b5ef461256727ff6793b/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/ValuesPanel.java#L588-L624","documentation":"The character field handler throws InputMismatchException(\"Only single character allowed\") when the field contains more than one character, since a char-sized (single-byte-slot) edit can only encode one character via codeArea.getCharset().","triggerScenarios":"characterTextFieldKeyReleased with characterText.length() > 1 — pasting multi-character text or typing a second character into the field.","commonSituations":"Pasting a word or multi-byte sequence into the character field; IME composition leaving multiple chars; intending a string edit but using the character field.","solutions":["Keep only one character in the field (delete the extra ones).","Use the string field instead for multi-character input.","Paste a single character, or paste into the string field which accepts longer text up to the cache size."],"exampleFix":"// before\ncharacterTextField.setText(\"AB\"); // throws\n// after\ncharacterTextField.setText(\"A\"); // or stringTextField.setText(\"AB\");","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    applyCharacterValue(characterTextField.getText());\n} catch (InputMismatchException e) {\n    setStatus(\"Enter exactly one character (use the string field for longer text)\");\n}","preventionTips":["Enforce a 1-char DocumentFilter on the character field.","Send multi-character input to the string field instead.","Handle paste events by truncating or redirecting to the string field."],"tags":["hexviewer","input-length","gui","validation"],"backgroundTag":"input-length-exceeded","analyzedSha":"31430e0033fa220db566b5ef461256727ff6793b","analyzedAt":"2026-09-05T18:22:22.725Z","contentChangedAt":"2026-09-05T18:22:22.725Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}