I need to do in Java, that in a JTextField only data can be copied, that is:
- not allow data to be entered directly from the keyboard
- just allow a data to be copied from another side and pasted into the JTextField.
Is this possible?
I need to do in Java, that in a JTextField only data can be copied, that is:
Is this possible?
JTextField
by default creates a keymap interface also referenced as DEFAULT_KEYMAP
.
A Keymap
(shared by all instances JTextComponent
) allows an application to join keystrokes to actions; Within those minimum actions are:
Passing null
to setKeymap()
is inactive the keyboard entry but still with the ability to paste the data from the clipboard.
miCampo.setKeymap(null);
Source: Documentation of JTextComponent
.
can be done by the method:
jTextField = new JTextField();
jTextField.setEditable(false); //no permite editar "a mano", pero si copiar
jTextField.setText("test2"); // ejemplo de edición aceptado