M
Madhur Ahuja
Hello
I have developed a Java Applet which contains swing buttons. The structure
of code is
as follows :
public class game extends Applet implements ActionListener
{
JButton x[][]=new JButton[3][3];
Button reset,start;
ImageIcon not,cross;
public void init()
{
for(int i=0;i<3;++i)
{
for(int j=0;j<3;++j)
{
x[j]=new JButton("");
x[j].setEnabled(false);
x[j].setVisible(true);
add(x[j]);
x[j].setLocation(50+j*100,20+i*100);
x[j].setSize(40,40);
x[j].addActionListener(this);
}
}
doLayout();
}
}
There are some problems with this applet :
1) First the when the applet starts, the buttons are not displayed although
I have set them explicitly
to setvisible in init().
2) Whenever a message box is displayed in the Applet, the buttons are not
redrawn, i.e. they loose
their visibility.
I think, to solve these problems I have to put some code in paint() method,
although I have no idea
what to put.
I am also confused about, which code should come in init() and what should
come in the constructor
of the applet. Is their any rule of thumb, like initialization code should
come in init() etc.
--
Winners dont do different things, they do things differently.
Madhur Ahuja
India
Homepage : http://madhur.netfirms.com
Email : madhur<underscore>ahuja<at>yahoo<dot>com
I have developed a Java Applet which contains swing buttons. The structure
of code is
as follows :
public class game extends Applet implements ActionListener
{
JButton x[][]=new JButton[3][3];
Button reset,start;
ImageIcon not,cross;
public void init()
{
for(int i=0;i<3;++i)
{
for(int j=0;j<3;++j)
{
x[j]=new JButton("");
x[j].setEnabled(false);
x[j].setVisible(true);
add(x[j]);
x[j].setLocation(50+j*100,20+i*100);
x[j].setSize(40,40);
x[j].addActionListener(this);
}
}
doLayout();
}
}
There are some problems with this applet :
1) First the when the applet starts, the buttons are not displayed although
I have set them explicitly
to setvisible in init().
2) Whenever a message box is displayed in the Applet, the buttons are not
redrawn, i.e. they loose
their visibility.
I think, to solve these problems I have to put some code in paint() method,
although I have no idea
what to put.
I am also confused about, which code should come in init() and what should
come in the constructor
of the applet. Is their any rule of thumb, like initialization code should
come in init() etc.
--
Winners dont do different things, they do things differently.
Madhur Ahuja
India
Homepage : http://madhur.netfirms.com
Email : madhur<underscore>ahuja<at>yahoo<dot>com