سؤال

I want a label to show the same as the text field has. Using KeyTyped falls behind one key stroke every time, while using KeyPressed does quite similar.

ActionPerformed does nothing until I hit enter.

private void myTextFieldKeyPressed(java.awt.event.KeyEvent evt) {
        cicloLabel.setText(myTextField.getText()+" horas apagado.");
    }

Any suggestions? Thanks in advance

هل كانت مفيدة؟

المحلول

You can use DocumentListener here and call setText on your label.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top