Re: Document Filtering Question



Chris wrote:
On May 28, 8:50 pm, Knute Johnson <nos...@xxxxxxxxxxxxxxxxxxxxxxx>
wrote:
Chris wrote:
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);
}
}
So maybe I don't really understand, you've got a text field that when
you type characters into the field they disappear but you really want to
save them somewhere? Is this supposed to be some sort of password field?

--

Knute Johnson
email s/knute/nospam/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access- Hide quoted text -

- Show quoted text -

No, no password field. I'm just trying to be able to type into a
textbox, and then automatically (1) store the text that was typed and
(2) clear the text.

Do you want to do it on every keystroke or just when the user leaves the text field?

--

Knute Johnson
email s/knute/nospam/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
.



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)
  • 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: Left justified text
    ... Left alignment in a horizontal box appears to be the default. ... public static void main{ ... Posted via NewsDemon.com - Premium Uncensored Newsgroup Service ... Unlimited Access, Anonymous Accounts, Uncensored Broadband Access ...
    (comp.lang.java.gui)
  • Re: Local garage breaks our cat during an MOT. Why always us?
    ... No emissions test or brake test done yet apparently, ... A replacement fitted on 27 05 05. ... Posted via NewsDemon.com - Premium Uncensored Newsgroup Service ... Unlimited Access, Anonymous Accounts, Uncensored Broadband Access ...
    (uk.rec.cars.maintenance)
  • Re: Local garage breaks our cat during an MOT. Why always us?
    ... No emissions test or brake test done yet apparently, ... A replacement fitted on 27 05 05. ... Posted via NewsDemon.com - Premium Uncensored Newsgroup Service ... Unlimited Access, Anonymous Accounts, Uncensored Broadband Access ...
    (uk.rec.cars.maintenance)