I have created an
applet and i am initialising my button in the init. But i am adding the buuton to the panel in the paint method and i am calling the repaint method in the start could u please help because the control is not visible as soon as the applet is loaded as well as when i lose the focus of the applet and get the focus of the applet again. I am also tying the code below for further understanding:
import javax.swing.*;
import java.awt.*;
public class Applettry extends JApplet
{
int count;
JButton b1;
JPanel panel;
public void init()
{
count=0;
panel=new JPanel();
getContentPane().add(panel);
b1=new JButton(String.valueOf(count));
}
public void start()
{
count++;
repaint();
}
public void paint(Graphics g)
{
panel.add(b1);
showStatus("trying");
}
}