i have jTextfield and jButton..
how to
- user can click on jTextfield(mouse can enter/exited on jtextfield), but if user typing something it will not do anything (except backspace that will remove entire text)
- when user click the button, it will
jTextfield.setText(“something”);
so the only way to give jtextfield text is click the button
- when there are a text in there (when cursor inside jtextfield) then user typing a backspace, it will remove entire text on jtextfield..
how to do this?
forgive my english..
thanks a lot for any kind of help..
Use a
DocumentFilter, simply add it to yourJTextFieldlike so:alternatively
You may want to create a custom JTextField which already has a
DocumentFilter(for re-usability) something like:Edit from Hovercraft
I was thinking more along these lines