Showing components of JFrame
I got a class which extends JFrame, this class contains only a JTextField that diplays the string argument in the field. I am trying to create two instances of this class, but only the second frame appears with the name while the first frame does not show anything.
Here is the code:
public class SimpleFrame extends JFrame {
static JTextField nameField = new JTextField();
public SimpleFrame (String Name){
nameField.setText(Name);
add(nameField);
setVisible(true);
pack();
}
public static void main(String[] args) {
SimpleFrame sf1 = new SimpleFrame("Tony");
SimpleFrame sf2 = new SimpleFrame("Nick");
}
}
when runing this Two JFrame appear but only the second one shows Nick while the first frame does not show Tony.?
Any help is appreciated.

