Re: Document Filtering Question



On May 28, 9:09 pm, Knute Johnson <nos...@xxxxxxxxxxxxxxxxxxxxxxx>
wrote:
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- Hide quoted text -

- Show quoted text -

I'm looking to do it on every keystroke. I tried writing a class
(below) using a text listener, but couldnt find a way to clear the
text after the text was entered. I tried setText(""); but an infinite
loop threw me a road block, hence my current attemp above.
Thank you by the way for your emails...

Chris



import java.awt.*;
import java.awt.event.*;


public class InputListener extends Frame implements TextListener {


public InputListener ( String s ) {
super ( s ) ;

setLayout ( null ) ;

TextField t = new TextField ( ) ;
t.setSize ( 300,300 ) ;
t.setLocation ( 50,50 ) ;


add ( t ) ;

t.addTextListener ( this ) ;

}


public void textValueChanged ( TextEvent e )
{
TextComponent tc = (TextComponent)e.getSource();
s = tc.getText();
System.out.println(s);
tc.setText(null);
}


public String txt()
{
return s;

}

}

.



Relevant Pages

  • Re: 11-string recuerdos- where on the bell curve?
    ...   Yes, a couple of the ornaments in the first section did not come out ... which there is not room for improvement, slurs included, but I do not ... This is my recording of Recuerdos done on six string several years ... a heavier bass? ...
    (rec.music.classical.guitar)
  • Re: Export multiple versions of a query to separate Excel files
    ... If I try to run the code I can select the folder that I want to create ... Dim qdf As DAO.QueryDef ... Dim strSQL As String, strTemp As String, strMgr As String ...
    (microsoft.public.access.externaldata)
  • Re: Using String for new List name
    ...     for line in infile: ... and aclS represents "access control list String." ... My quest, if you will, is to create a list of syslog entries, each ... Since ACL rules can be written with a range of granularity, ...
    (comp.lang.python)
  • Re: Macro to delete rows until a row contains a certain text strin
    ... Dim rngStartCell As Range ... Dim strToFindStart As String ...     'Test if any rows between first and last identifiers ... starting cell to one row before the row containing "KM In". ...
    (microsoft.public.excel.programming)
  • Re: Excel Chart Macro Issue
    ... If the issue is string length, why would forming a large string at the end ... Sometimes this means setting up a summary range that the chart uses. ... Dim rDataX As Range ...   Dim wsData As Worksheet ...
    (microsoft.public.excel.programming)