DocumentListener is too slow
- From: "William Z." <Wizumwalt@xxxxxxxxx>
- Date: 3 Nov 2005 15:27:38 -0800
I'm trying to enter information into some form objects where I store my
data but this is kind of slow what I have. The problem is that when a
user types information into my Swing form, everything listed in my
changedUpdate() method (below) gets executed for each character typed.
I have a DocumentListener for each JTextField of my forms (avg. of 10
fields per form and there are 10 forms/JPanels). When the user enters
text into a field, I do the following ...
// class constructor
public TextFieldListener(JLabel label, ...) { ... }
public void changedUpdate( DocumentEvent de ) {
Document doc = de.getDocument();
// Since this listener is registered to a material form,
// I get the current material definition from FormDefinitions
// which is a static Hashtable of form types
int matId = FormDefinitions.getInstance().getCurrentMaterial();
Material material = (Material)
FormDefinitions.getInstance().get(MATERIAL_FORM, matId);
// get user typed input
String txt = doc.getText(0, doc.getLength());
// set info to my material object
if (label.getText().equals("weight")) {
material.setWeight(new Integer(txt));
}
else if (label.getText().equals("id")) {
material.setId(new Integer(txt));
}
// put the new information/material back in my storage of all form
info.
FormDefinitions.getInstance().replace(MATERIAL_FORM, matId,
material);
}
Does anyone have any better ideas, cause I don't know how to enter this
information when a user is done with a field. User doesn't have to hit
the enter key or anything. When it's typed in, it should be stored.
Any help much appreciated.
.
- Follow-Ups:
- Re: DocumentListener is too slow
- From: pit . grinja
- Re: DocumentListener is too slow
- From: pit . grinja
- Re: DocumentListener is too slow
- From: Thomas Hawtin
- Re: DocumentListener is too slow
- From: Andrew Thompson
- Re: DocumentListener is too slow
- Prev by Date: Re: newbie JSP question
- Next by Date: Re: DocumentListener is too slow
- Previous by thread: newbie JSP question
- Next by thread: Re: DocumentListener is too slow
- Index(es):