Help writing your own javax.swing.text.Document

I am writing a Java TextComponent where the base document has some structure. This is a very short, mostly one line. I need to be able to cancel the response to insert or delete characters in some parts of the document.

My initial approach was to implement javax.swing.text.Document, but it seems to be related to the development of many related classes (Element, EditorKit, View), and there seem to be not many examples or tutorials on how To do this, there are many options for using predefined implementations.

Can someone point me to textbooks or other helpers for simple document implementations and what other classes I need to create in order to make this work.

+3
source share
3 answers

If you just want to respond to character input / deletion, DocumentFilter is probably the best approach. This will allow you to prevent the insertion of characters in the Document, you so desire. Read the JTextField API and follow the link to the Swing tutorial on “Text Component Functions” for more information.

+2
source
+3

EditorKit - - , javax.swing.text.Document.

+2

Source: https://habr.com/ru/post/1738503/


All Articles