Can't get reuuestFocus to work
I'm new to Java and having trouble getting requestFocus to place the cursor in a JtextField. I've written a little program to play with but can't get it to work. What am I'm missing?
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class testreplyfocus extends JApplet implements ActionListener
{
JLabel prompt = new JLabel ("Test Request Focus");
JButton but = new JButton("Button");
JTextField text = new JTextField("",10);
FlowLayout flow = new FlowLayout();
public void init()
{
Container con = getContentPane();
con.add(prompt);
con.add(but);
con.add(text);
con.setLayout(flow);
but.addActionListener(this);
text.requestFocus()
}
public void actionPerformed(ActionEvent thisEvent)
{
Object source = thisEvent.getSource();
text.requestFocus();
if (source == text)
{
System.out.println ("Worked");
}
}
}
Thanks!