I have a JTextField
. And when the user enters a
or j
, I want the text within the text field to be upper-case (e.g. enter "ab", output "AB"). And if the first letter is not one of the following,
a
,t
,j
,q
,k
,2
,3
, ...,9
I don't want the text field to display anything.
And here's what I have,
public class Gui {
JTextField tf;
public Gui(){
tf = new JTextField();
tf.addKeyListener(new KeyListener(){
public void keyTyped(KeyEvent e) {
}
/** Handle the key-pressed event from the text field. */
public void keyPressed(KeyEvent e) {
}
/** Handle the key-released event from the text field. */
public void keyReleased(KeyEvent e) {
}
});
}
}