Document Filtering Question



All,
I am missing something with regard to document filtering. I have
successfully built this app where the text clears (actually gets
replaced with "") everytime a keystoke is entered into my textField.
However, before the replacement with ("") I would like to somehow save
the text that is coming in to the textField (in a String variable
perhaps?).
Anyhow, your expertise would be very much appreciated.

Thank you,
Chris

import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.text.AbstractDocument;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.DocumentFilter;



public class textAreaExample {

public static void main(String[] args) {
clear();

}
public static void clear() {
final JTextField field = new JTextField(30);

((AbstractDocument) (field.getDocument())).setDocumentFilter(new
DocumentFilter()
{

public void replace(FilterBypass fb, int offset, int length,
String string, AttributeSet attr)
throws BadLocationException {
fb.replace(offset, length, "", attr);

}

});

JFrame frame = new JFrame("ALiiS");
frame.getContentPane().add(field);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);


}
}
.



Relevant Pages

  • Re: Document Filtering Question
    ... I am missing something with regard to document filtering. ... before the replacement with I would like to somehow save ... public static void main{ ... String string, AttributeSet attr) ...
    (comp.lang.java.gui)
  • Re: Document Filtering Question
    ... I am missing something with regard to document filtering. ... before the replacement with I would like to somehow save ... public static void main{ ... Posted via NewsDemon.com - Premium Uncensored Newsgroup Service ...
    (comp.lang.java.gui)
  • Re: Document Filtering Question
    ...  I am missing something with regard to document filtering. ... before the replacement with I would like to somehow save ...   final JTextField field = new JTextField; ... String string, AttributeSet attr) ...
    (comp.lang.java.gui)
  • How to use Log4net TelnetAppender and Trace Listeners
    ... Is there a way to use Log4net and Trace Listeners? ... public static void Initialize(string traceListeners, ... public static void Flush2File(string file, string msg, bool ...
    (microsoft.public.dotnet.framework)
  • Re: must find print packages which can deal with large charts
    ... list available printers, query a named printer, print text and image files ... String inputFileName = null; ... printToFile(outputFileName, outputFileType, ... public static void queryServices{ ...
    (comp.lang.java.gui)