How to clear or reset or
To: comp.lang.java.gui
All,
I have a question regarding my little app below. I created and added
a Text Field to a JFrame. I then built an inner class to handle a
textlistner.
My question is in the IF/ELSE block of the textlistener class. I would
like for both IF and ELSE to reset or clear the Text Field at the end
of each block, but do not know how. That is, I will fill in some code
at the begning of IF and ELSE (calls to a database), but then need the
words residing in the Text Field to clear out so I can recursively re-
run this app (have it always cycling). I had an expert last week help
me with something similar, but I can't quite figure out how to do this
without using setText("") which sends this into an infinite loop.
Your time is very much appriciated.
Thank you.
---------------------------------------------------------------------------------------------------------------------------------------------------------------
package ALIIS;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JFrame;
public class InputListener extends JFrame
{
public static void main (String [] args)
{
new InputListener();
}
public InputListener ()
{
this.setSize(300,300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setTitle("ALiiS");
JPanel panel1 = new JPanel();
ALiiSTextListen atl = CListen();
TextField t = new TextField();
t.setSize(300, 300);
t.addTextListener(atl);
add ( t ) ;
this.add(panel1);
this.setVisible (true);
}
public class Clisten implements TextListener
{
public void textValueChanged ( TextEvent e )
{
TextComponent tc = (TextComponent)e.getSource();
String inputrules = tc.getText();
if (inputrules == "Chris")
{
//Here I need to somehow refresh the textfield
}
else
{
// Here as well...
}
}
}
}
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24