i have two classes. Main class and tester class. I have to create a textfield so your can enter there name. The problem is that in tester class i am getting error on add() method. is there simple fix for this? i want to create the textfield in tester class tho.
Main class
...
public void init()
{
setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
displayClass = new Display();
setContentPane(displayClass);
setFocusable(true);
addKeyListener(this); //keys
addMouseListener(this); //clicking
addMouseMotionListener(this); //mouse motion
}
...
public class Display extends JPanel
{
public void paintComponent(Graphics g)
{
super.paintComponent(g);
testerObject.paint(g);
}
}
tester Class
...
JTextField jName = new JTextField(10);
...
public void paint(Graphics g)
{
jName.requestFocus();
jName.setBounds(900, 300, 100, 20);
add(jName);
}
}