Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Document Filter insertString method in Oracle Java Tutorial for JTextComponent  RSS feed

 
simon fletcher
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the Oracle Java Tutorial for Text Component Features, the insertString(FilterBypass fb, int offs, String str, AttributeSet a) method, (the code for it can be found at TextComponentDemo and DocumentSizeFilter), which is supposed to require four arguments, gets called in the line...

...with only three arguments.

I see the arguments for offset, String, and attribute but why is the one for FilterBypass not needed in this invocation of the method?

Thanks.
 
Rob Camick
Ranch Hand
Posts: 2801
15
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Document is responsible for invoking the DocumentFilter, not your application code.

Your application code is only responsible for adding the text to the Document, so you only specify the parameters that are directly needed by the Document. Your application code does not need to be aware of the internal workings of the Document.
 
simon fletcher
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am I correct in interpreting what you're saying as the code I would write would only invoke the insertString method of, say, the DefaultStyledDocument, PlainDocument, or any ones that I extend from those, and never directly the one from the DocumentFilter?
 
Paul Clapham
Sheriff
Posts: 22503
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that is correct.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!