- fileOptionsRenameTextField.getDocument().addDocumentListener(new DocumentListener() {
-
- @SuppressWarnings("synthetic-access")
- private void storeText(DocumentEvent documentEvent) {
- FileOption fileOption = getSelectedFile();
- if (fileOption == null) {
- /* no file selected. */
- return;
- }
- Document document = documentEvent.getDocument();
- int documentLength = document.getLength();
- try {
- fileOption.setChangedName(document.getText(0, documentLength).trim());
- } catch (BadLocationException ble1) {
- /* ignore, it should never happen. */
- }
- }
-
- @Override
- public void changedUpdate(DocumentEvent documentEvent) {
- storeText(documentEvent);
- }
-
- @Override
- public void insertUpdate(DocumentEvent documentEvent) {
- storeText(documentEvent);
- }
-
- @Override
- public void removeUpdate(DocumentEvent documentEvent) {
- storeText(documentEvent);
- }
-
- });