here is my program and hope u could help me solve my problem on how to repeat this whole game program when the player chooses the the Yes button which indicates that he'd like to play again.

a:\master1.java

I don't see any code... and try to make some headway into the problem yourself... it's bad to simply ask on these forums for homework answers. Try to learn something.

here is my program and hope u could help me solve my problem on how to repeat this whole game program when the player chooses the the Yes button which indicates that he'd like to play again.

a:\master1.java

you know cosi is so helping .. . always positive.... :)

post your code so we can see what you have and help you out :)

sorry guys, here is my code:

import java.awt.*;
import java.lang.Math;
import java.applet.Applet;
import javax.swing.*;
import java.awt.event.*;



public class mastermind extends Applet implements ActionListener
{


int tri=0,put=1,set=1,t,in=0,w,n,ctr=0,c=0,x,win=0,lose=0,pasaloadcp=0,pasaloadset=0;
int [] secretCol;
int tapos[]={-1,-1,-1};
int pickCol[];
int copyy[];


Label peglbl1=new Label("");
Label peglbl2=new Label("");
Label peglbl3=new Label("");
Label peglbl4=new Label("");
Label peglbl5=new Label("");
Label peglbl6=new Label("");
Label peglbl7=new Label("");
Label peglbl8=new Label("");
Label peglbl9=new Label("");
Label peglbl10=new Label("");
Label peglbl11=new Label("");
Label peglbl12=new Label("");
Label peglbl13=new Label("");
Label peglbl14=new Label("");
Label peglbl15=new Label("");
Button colbtn1=new Button();
Button colbtn2=new Button();
Button colbtn3=new Button();
Button colbtn4=new Button();
Button colbtn5=new Button();
Button colbtn6=new Button();
Label gnolbl1=new Label("Guess #1");
Label gnolbl2=new Label("Guess #2");
Label gnolbl3=new Label("Guess #3");
Label gnolbl4=new Label("Guess #4");
Label gnolbl5=new Label("Guess #5");
Label winlbl=new Label("WIN");
Label loselbl=new Label("LOSE");
Label clulbl1=new Label("");
Label clulbl2=new Label("");
Label clulbl3=new Label("");
Label clulbl4=new Label("");
Label clulbl5=new Label("");
Label clulbl6=new Label("");
Label clulbl7=new Label("");
Label clulbl8=new Label("");
Label clulbl9=new Label("");
Label clulbl10=new Label("");
Label clulbl12=new Label("");



Label blbl2=new Label("");
Label blbl4=new Label("");


Label slbl2=new Label("");
Label slbl3=new Label("");
Label slbl4=new Label("");


Label sclbl1=new Label("0");
Label sclbl2=new Label("0");


public void init()
{


pickCol=new int[3];
tapos=new int[3];
copyy=new int[3];


setLayout(new GridLayout(8,6,5,5));
colbtn1.addActionListener(this);
colbtn2.addActionListener(this);
colbtn3.addActionListener(this);
colbtn4.addActionListener(this);
colbtn5.addActionListener(this);
colbtn6.addActionListener(this);


add(gnolbl1);
add(peglbl1);
add(peglbl2);
add(peglbl3);
add(clulbl1);
add(clulbl2);


add(gnolbl2);
add(peglbl4);
add(peglbl5);
add(peglbl6);
add(clulbl3);
add(clulbl4);


add(gnolbl3);
add(peglbl7);
add(peglbl8);
add(peglbl9);
add(clulbl5);
add(clulbl6);


add(gnolbl4);
add(peglbl10);
add(peglbl11);
add(peglbl12);
add(clulbl7);
add(clulbl8);


add(gnolbl5);
add(peglbl13);
add(peglbl14);
add(peglbl15);
add(clulbl9);
add(clulbl10);


add(colbtn1);
add(colbtn2);
add(colbtn3);
add(colbtn4);
add(colbtn5);
add(colbtn6);


peglbl1.setBackground(Color.DARK_GRAY);
peglbl2.setBackground(Color.DARK_GRAY);
peglbl3.setBackground(Color.DARK_GRAY);
peglbl4.setBackground(Color.DARK_GRAY);
peglbl5.setBackground(Color.DARK_GRAY);
peglbl6.setBackground(Color.DARK_GRAY);
peglbl7.setBackground(Color.DARK_GRAY);
peglbl8.setBackground(Color.DARK_GRAY);
peglbl9.setBackground(Color.DARK_GRAY);
peglbl10.setBackground(Color.DARK_GRAY);
peglbl11.setBackground(Color.DARK_GRAY);
peglbl12.setBackground(Color.DARK_GRAY);
peglbl13.setBackground(Color.DARK_GRAY);
peglbl14.setBackground(Color.DARK_GRAY);
peglbl15.setBackground(Color.DARK_GRAY);


gnolbl1.setBackground(Color.LIGHT_GRAY);
gnolbl2.setBackground(Color.LIGHT_GRAY);
gnolbl3.setBackground(Color.LIGHT_GRAY);
gnolbl4.setBackground(Color.LIGHT_GRAY);
gnolbl5.setBackground(Color.LIGHT_GRAY);


clulbl1.setBackground(Color.LIGHT_GRAY);
clulbl2.setBackground(Color.LIGHT_GRAY);
clulbl3.setBackground(Color.LIGHT_GRAY);
clulbl4.setBackground(Color.LIGHT_GRAY);
clulbl5.setBackground(Color.LIGHT_GRAY);
clulbl6.setBackground(Color.LIGHT_GRAY);
clulbl7.setBackground(Color.LIGHT_GRAY);
clulbl8.setBackground(Color.LIGHT_GRAY);
clulbl9.setBackground(Color.LIGHT_GRAY);
clulbl10.setBackground(Color.LIGHT_GRAY);


colbtn1.setLabel("Green");
colbtn2.setLabel("Blue");
colbtn3.setLabel("Red");
colbtn4.setLabel("Yellow");
colbtn5.setLabel("Orange");
colbtn6.setLabel("Magenta");
colbtn1.setBackground(Color.GREEN);
colbtn2.setBackground(Color.BLUE);
colbtn3.setBackground(Color.RED);
colbtn4.setBackground(Color.YELLOW);
colbtn5.setBackground(Color.ORANGE);
colbtn6.setBackground(Color.MAGENTA);



add(winlbl);
add(sclbl1);
add(blbl2);
add(loselbl);
add(sclbl2);
add(blbl4);



add(slbl2);
add(slbl3);
add(slbl4);


}//init


public void start()
{
double m;
int k,a;
secretCol=new int[3];
for(a=0;a<3;a++)
{
secretCol[a]=-1;
while(secretCol[a]<0)
{
m=Math.random();
k=(int) Math.floor((m*6)+1);
secretCol[a]=k;
}
}


for(a=0;a<3;a++)
{
if(a==0)
{
if(secretCol[a]==1)
slbl2.setBackground(Color.GREEN);
else if(secretCol[a]==2)
slbl2.setBackground(Color.BLUE);
else if(secretCol[a]==3)
slbl2.setBackground(Color.RED);
else if(secretCol[a]==4)
slbl2.setBackground(Color.YELLOW);
else if(secretCol[a]==5)
slbl2.setBackground(Color.ORANGE);
else if(secretCol[a]==6)
slbl2.setBackground(Color.MAGENTA);
}
else if(a==1)
{
if(secretCol[a]==1)
slbl3.setBackground(Color.GREEN);
else if(secretCol[a]==2)
slbl3.setBackground(Color.BLUE);
else if(secretCol[a]==3)
slbl3.setBackground(Color.RED);
else if(secretCol[a]==4)
slbl3.setBackground(Color.YELLOW);
else if(secretCol[a]==5)
slbl3.setBackground(Color.ORANGE);
else if(secretCol[a]==6)
slbl3.setBackground(Color.MAGENTA);
}
else if(a==2)
{
if(secretCol[a]==1)
slbl4.setBackground(Color.GREEN);
else if(secretCol[a]==2)
slbl4.setBackground(Color.BLUE);
else if(secretCol[a]==3)
slbl4.setBackground(Color.RED);
else if(secretCol[a]==4)
slbl4.setBackground(Color.YELLOW);
else if(secretCol[a]==5)
slbl4.setBackground(Color.ORANGE);
else if(secretCol[a]==6)
slbl4.setBackground(Color.MAGENTA);
}
}
}//clrBoard


public void actionPerformed(ActionEvent ae)
{


int rightcp=0,rightcol=0;
int what=0;


tri++;
if(ae.getSource()==colbtn1)
{
if(tri==1)
peglbl1.setBackground(Color.GREEN);
else if(tri==2)
peglbl2.setBackground(Color.GREEN);
else if(tri==3)
peglbl3.setBackground(Color.GREEN);
else if(tri==4)
peglbl4.setBackground(Color.GREEN);
else if(tri==5)
peglbl5.setBackground(Color.GREEN);
else if(tri==6)
peglbl6.setBackground(Color.GREEN);
else if(tri==7)
peglbl7.setBackground(Color.GREEN);
else if(tri==8)
peglbl8.setBackground(Color.GREEN);
else if(tri==9)
peglbl9.setBackground(Color.GREEN);
else if(tri==10)
peglbl10.setBackground(Color.GREEN);
else if(tri==11)
peglbl11.setBackground(Color.GREEN);
else if(tri==12)
peglbl12.setBackground(Color.GREEN);
else if(tri==13)
peglbl13.setBackground(Color.GREEN);
else if(tri==14)
peglbl14.setBackground(Color.GREEN);
else if(tri==15)
peglbl15.setBackground(Color.GREEN);
what=1;
}
else if(ae.getSource()==colbtn2)
{


if(tri==1)
peglbl1.setBackground(Color.BLUE);
else if(tri==2)
peglbl2.setBackground(Color.BLUE);
else if(tri==3)
peglbl3.setBackground(Color.BLUE);
else if(tri==4)
peglbl4.setBackground(Color.BLUE);
else if(tri==5)
peglbl5.setBackground(Color.BLUE);
else if(tri==6)
peglbl6.setBackground(Color.BLUE);
else if(tri==7)
peglbl7.setBackground(Color.BLUE);
else if(tri==8)
peglbl8.setBackground(Color.BLUE);
else if(tri==9)
peglbl9.setBackground(Color.BLUE);
else if(tri==10)
peglbl10.setBackground(Color.BLUE);
else if(tri==11)
peglbl11.setBackground(Color.BLUE);
else if(tri==12)
peglbl12.setBackground(Color.BLUE);
else if(tri==13)
peglbl13.setBackground(Color.BLUE);
else if(tri==14)
peglbl14.setBackground(Color.BLUE);
else if(tri==15)
peglbl15.setBackground(Color.BLUE);
what=2;
}
else if(ae.getSource()==colbtn3)
{
if(tri==1)
peglbl1.setBackground(Color.RED);
else if(tri==2)
peglbl2.setBackground(Color.RED);
else if(tri==3)
peglbl3.setBackground(Color.RED);
else if(tri==4)
peglbl4.setBackground(Color.RED);
else if(tri==5)
peglbl5.setBackground(Color.RED);
else if(tri==6)
peglbl6.setBackground(Color.RED);
else if(tri==7)
peglbl7.setBackground(Color.RED);
else if(tri==8)
peglbl8.setBackground(Color.RED);
else if(tri==9)
peglbl9.setBackground(Color.RED);
else if(tri==10)
peglbl10.setBackground(Color.RED);
else if(tri==11)
peglbl11.setBackground(Color.RED);
else if(tri==12)
peglbl12.setBackground(Color.RED);
else if(tri==13)
peglbl13.setBackground(Color.RED);
else if(tri==14)
peglbl14.setBackground(Color.RED);
else if(tri==15)
peglbl15.setBackground(Color.RED);
what=3;
}
else if(ae.getSource()==colbtn4)
{
if(tri==1)
peglbl1.setBackground(Color.YELLOW);
else if(tri==2)
peglbl2.setBackground(Color.YELLOW);
else if(tri==3)
peglbl3.setBackground(Color.YELLOW);
else if(tri==4)
peglbl4.setBackground(Color.YELLOW);
else if(tri==5)
peglbl5.setBackground(Color.YELLOW);
else if(tri==6)
peglbl6.setBackground(Color.YELLOW);
else if(tri==7)
peglbl7.setBackground(Color.YELLOW);
else if(tri==8)
peglbl8.setBackground(Color.YELLOW);
else if(tri==9)
peglbl9.setBackground(Color.YELLOW);
else if(tri==10)
peglbl10.setBackground(Color.YELLOW);
else if(tri==11)
peglbl11.setBackground(Color.YELLOW);
else if(tri==12)
peglbl12.setBackground(Color.YELLOW);
else if(tri==13)
peglbl13.setBackground(Color.YELLOW);
else if(tri==14)
peglbl14.setBackground(Color.YELLOW);
else if (tri==15)
peglbl15.setBackground(Color.YELLOW);
what=4;
}
else if(ae.getSource()==colbtn5)
{
if(tri==1)
peglbl1.setBackground(Color.ORANGE);
else if(tri==2)
peglbl2.setBackground(Color.ORANGE);
else if(tri==3)
peglbl3.setBackground(Color.ORANGE);
else if(tri==4)
peglbl4.setBackground(Color.ORANGE);
else if(tri==5)
peglbl5.setBackground(Color.ORANGE);
else if(tri==6)
peglbl6.setBackground(Color.ORANGE);
else if(tri==7)
peglbl7.setBackground(Color.ORANGE);
else if(tri==8)
peglbl8.setBackground(Color.ORANGE);
else if(tri==9)
peglbl9.setBackground(Color.ORANGE);
else if(tri==10)
peglbl10.setBackground(Color.ORANGE);
else if(tri==11)
peglbl11.setBackground(Color.ORANGE);
else if(tri==12)
peglbl12.setBackground(Color.ORANGE);
else if(tri==13)
peglbl13.setBackground(Color.ORANGE);
else if(tri==14)
peglbl14.setBackground(Color.ORANGE);
else if(tri==15)
peglbl15.setBackground(Color.ORANGE);
what=5;
}
else if(ae.getSource()==colbtn6)
{
if(tri==1)
peglbl1.setBackground(Color.MAGENTA);
else if(tri==2)
peglbl2.setBackground(Color.MAGENTA);
else if(tri==3)
peglbl3.setBackground(Color.MAGENTA);
else if(tri==4)
peglbl4.setBackground(Color.MAGENTA);
else if(tri==5)
peglbl5.setBackground(Color.MAGENTA);
else if(tri==6)
peglbl6.setBackground(Color.MAGENTA);
else if(tri==7)
peglbl7.setBackground(Color.MAGENTA);
else if(tri==8)
peglbl8.setBackground(Color.MAGENTA);
else if(tri==9)
peglbl9.setBackground(Color.MAGENTA);
else if(tri==10)
peglbl10.setBackground(Color.MAGENTA);
else if(tri==11)
peglbl11.setBackground(Color.MAGENTA);
else if(tri==12)
peglbl12.setBackground(Color.MAGENTA);
else if(tri==13)
peglbl13.setBackground(Color.MAGENTA);
else if(tri==14)
peglbl14.setBackground(Color.MAGENTA);
else if(tri==15)
peglbl15.setBackground(Color.MAGENTA);
what=6;
}


ctr=ctr+1;
pickCol[in++]=what;


if(ctr==3)
{


for(w=0;w<3;w++)
copyy[w]=secretCol[w];


for(w=0;w<3;w++)
{


if(pickCol[w]==secretCol[w])
{
rightcp=rightcp+1;
tapos[w]=pickCol[w];
}
}


for(w=0;w<3;w++)
for(x=0;x<3;x++)
if(pickCol[w]==tapos[w])
break;
else if(w==x)
continue;
else if(pickCol[w]==tapos[x])
continue;
else if(pickCol[w]==copyy[x])
{
rightcol=rightcol+1;
copyy[x]=-1;
break;
}



if(set==1)
{
if(rightcp==0)
clulbl1.setText("0");
else if(rightcp==1)
clulbl1.setText("1");
else if(rightcp==2)
clulbl1.setText("2");
else if(rightcp==3)
clulbl1.setText("3");


if(rightcol==0)
clulbl2.setText("0");
else if(rightcol==1)
clulbl2.setText("1");
else if(rightcol==2)
clulbl2.setText("2");
else if(rightcol==3)
clulbl2.setText("3");
pasaloadset=set;
if(rightcp==3 && set<=5)
{
win++;
sclbl1.setText(win+"");
JOptionPane.showMessageDialog(null,"Congratulations you WIN!!!","Resulta",JOptionPane.INFORMATION_MESSAGE);
set=0;
}
else if ((rightcp<3) && (set==5))
{
set=0;
lose++;
sclbl2.setText(lose+"");
JOptionPane.showMessageDialog(null,"Sorry you LOSE.","Resulta",JOptionPane.INFORMATION_MESSAGE);
}
pasaloadcp=rightcp;
rightcp=0;
rightcol=0;
in=0;
ctr=0;
tapos[0]=-1;
tapos[1]=-1;
tapos[2]=-1;
}
else if(set==2)
{
if(rightcp==0)
clulbl3.setText("0");
else if(rightcp==1)
clulbl3.setText("1");
else if(rightcp==2)
clulbl3.setText("2");
else if(rightcp==3)
clulbl3.setText("3");


if(rightcol==0)
clulbl4.setText("0");
else if(rightcol==1)
clulbl4.setText("1");
else if(rightcol==2)
clulbl4.setText("2");
else if(rightcol==3)
clulbl4.setText("3");
pasaloadset=set;
if(rightcp==3 && set<=5)
{
set=0;
win++;
sclbl1.setText(win+"");
JOptionPane.showMessageDialog(null,"Congratulations you WIN!!!","Resulta",JOptionPane.INFORMATION_MESSAGE);
}


else if ((rightcp<3) && (set==5))
{
set=0;
lose++;
sclbl2.setText(lose+"");
JOptionPane.showMessageDialog(null,"Sorry you LOSE.","Resulta",JOptionPane.INFORMATION_MESSAGE);


}
pasaloadcp=rightcp;
rightcp=0;
rightcol=0;
in=0;
ctr=0;
tapos[0]=-1;
tapos[1]=-1;
tapos[2]=-1;


}
else if(set==3)
{
if(rightcp==0)
clulbl5.setText("0");
else if(rightcp==1)
clulbl5.setText("1");
else if(rightcp==2)
clulbl5.setText("2");
else if(rightcp==3)
clulbl5.setText("3");


if(rightcol==0)
clulbl6.setText("0");
else if(rightcol==1)
clulbl6.setText("1");
else if(rightcol==2)
clulbl6.setText("2");
else if(rightcol==3)
clulbl6.setText("3");
pasaloadset=set;
if(rightcp==3 && set<=5)
{
win++;
sclbl1.setText(win+"");
JOptionPane.showMessageDialog(null,"Congratulations you WIN!!!","Resulta",JOptionPane.INFORMATION_MESSAGE);
set=0;


}
else if ((rightcp<3) && (set==5))
{
lose++;
sclbl2.setText(lose+"");
JOptionPane.showMessageDialog(null,"Sorry you LOSE.","Resulta",JOptionPane.INFORMATION_MESSAGE);
set=0;
}
pasaloadcp=rightcp;
rightcp=0;
rightcol=0;
in=0;
ctr=0;
tapos[0]=-1;
tapos[1]=-1;
tapos[2]=-1;
}
else if(set==4)
{
if(rightcp==0)
clulbl7.setText("0");
else if(rightcp==1)
clulbl7.setText("1");
else if(rightcp==2)
clulbl7.setText("2");
else if(rightcp==3)
clulbl7.setText("3");


if(rightcol==0)
clulbl8.setText("0");
else if(rightcol==1)
clulbl8.setText("1");
else if(rightcol==2)
clulbl8.setText("2");
else if(rightcol==3)
clulbl8.setText("3");


pasaloadset=set;
if(rightcp==3 && set<=5)
{
win++;
sclbl1.setText(win+"");
JOptionPane.showMessageDialog(null,"Congratulations you WIN!!!","Resulta",JOptionPane.INFORMATION_MESSAGE);
set=0;
}
else if ((rightcp<3) && (set==5))
{
lose++;
sclbl2.setText(lose+"");
JOptionPane.showMessageDialog(null,"Sorry you LOSE.","Resulta",JOptionPane.INFORMATION_MESSAGE);
set=0;
}


pasaloadcp=rightcp;
rightcp=0;
rightcol=0;
in=0;
ctr=0;
tapos[0]=-1;
tapos[1]=-1;
tapos[2]=-1;
}
else if(set==5)
{
if(rightcp==0)
clulbl9.setText("0");
else if(rightcp==1)
clulbl9.setText("1");
else if(rightcp==2)
clulbl9.setText("2");
else if(rightcp==3)
clulbl9.setText("3");


if(rightcol==0)
clulbl10.setText("0");
else if(rightcol==1)
clulbl10.setText("1");
else if(rightcol==2)
clulbl10.setText("2");
else if(rightcol==3)
clulbl10.setText("3");


pasaloadset=set;
if(rightcp==3 && set<=5)
{
win++;
sclbl1.setText(win+"");
JOptionPane.showMessageDialog(null,"Congratulations you WIN!!!","Resulta",JOptionPane.INFORMATION_MESSAGE);
set=0;


}
else if ((rightcp<3) && (set==5))
{
lose++;
sclbl2.setText(lose+"");
JOptionPane.showMessageDialog(null,"Sorry you LOSE.","Resulta",JOptionPane.INFORMATION_MESSAGE);
set=0;
}
pasaloadcp=rightcp;
rightcp=0;
rightcol=0;
in=0;
ctr=0;
tapos[0]=-1;
tapos[1]=-1;
tapos[2]=-1;
}


if(pasaloadcp==3 && pasaloadset<=5)
{
/*******************************/
int intAns =JOptionPane.showConfirmDialog
(null, "Play Again?","Confirmation", JOptionPane.YES_NO_OPTION);
if (intAns == JOptionPane.YES_OPTION)
{
;
}
else
{
JOptionPane.showMessageDialog(null,"THANK YOU","",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
/***************************/
}
else if(pasaloadcp<3 && pasaloadset==5)
{
/*******************************/
int intAns =JOptionPane.showConfirmDialog
(null, "Play Again?","Confirmation", JOptionPane.YES_NO_OPTION);
if (intAns == JOptionPane.YES_OPTION)
;
else
{
JOptionPane.showMessageDialog(null,"Thank You!!!","",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
/***************************/
}
set=set+1;
}//if
}//class


}//class

sorry guys i thought i already attached my code.. but this is my program. the program is done except for a problem how to repeat the game once the player chooses the Yes button after he/she is asked to Play Again.

thanks for any help that u can give...

import java.awt.*;
import java.lang.Math;
import java.applet.Applet;
import javax.swing.*;
import java.awt.event.*;


public class mastermind extends Applet implements ActionListener
{

	int tri=0,put=1,set=1,t,in=0,w,n,ctr=0,c=0,x,win=0,lose=0,pasaloadcp=0,pasaloadset=0;
	int [] secretCol;
	int tapos[]={-1,-1,-1};
	int pickCol[];
   	 int copyy[];	
	
	Label peglbl1=new Label("");
	Label peglbl2=new Label("");
	Label peglbl3=new Label("");
	Label peglbl4=new Label("");
	Label peglbl5=new Label("");
	Label peglbl6=new Label("");
	Label peglbl7=new Label("");
	Label peglbl8=new Label("");
	Label peglbl9=new Label(""); 
	Label peglbl10=new Label("");
	Label peglbl11=new Label("");
	Label peglbl12=new Label("");
	Label peglbl13=new Label("");
	Label peglbl14=new Label("");
	Label peglbl15=new Label("");
	Button colbtn1=new Button();
	Button colbtn2=new Button();
	Button colbtn3=new Button();
	Button colbtn4=new Button();
	Button colbtn5=new Button();
	Button colbtn6=new Button();
	Label gnolbl1=new Label("Guess #1");
	Label gnolbl2=new Label("Guess #2");
	Label gnolbl3=new Label("Guess #3");
	Label gnolbl4=new Label("Guess #4");
	Label gnolbl5=new Label("Guess #5");
	Label winlbl=new Label("WIN");
	Label loselbl=new Label("LOSE");
	Label clulbl1=new Label("");
	Label clulbl2=new Label("");
	Label clulbl3=new Label("");
	Label clulbl4=new Label("");
	Label clulbl5=new Label("");
	Label clulbl6=new Label("");
	Label clulbl7=new Label("");
	Label clulbl8=new Label("");
	Label clulbl9=new Label("");
	Label clulbl10=new Label("");
	Label clulbl12=new Label("");
	
	
	Label blbl2=new Label("");
	Label blbl4=new Label("");
	
	//Label slbl2=new Label("");
	//Label slbl3=new Label("");
	//Label slbl4=new Label("");
	
	Label sclbl1=new Label("0");
	Label sclbl2=new Label("0");
	
	public void init()
	{
	
		pickCol=new int[3];
		tapos=new int[3];
		copyy=new int[3];
		
		setLayout(new GridLayout(8,6,5,5));	
		colbtn1.addActionListener(this);
		colbtn2.addActionListener(this);
		colbtn3.addActionListener(this);
		colbtn4.addActionListener(this);	
		colbtn5.addActionListener(this);
		colbtn6.addActionListener(this);
		
		add(gnolbl1);
		add(peglbl1);
		add(peglbl2);
		add(peglbl3);
		add(clulbl1);
		add(clulbl2);
		
		add(gnolbl2);
		add(peglbl4); 
		add(peglbl5);
		add(peglbl6);
		add(clulbl3);
		add(clulbl4);
		
		add(gnolbl3);
		add(peglbl7);
		add(peglbl8);
		add(peglbl9);
		add(clulbl5);
		add(clulbl6);
		
		add(gnolbl4);
		add(peglbl10);
		add(peglbl11);
		add(peglbl12);
		add(clulbl7);
		add(clulbl8);
		
		add(gnolbl5);
		add(peglbl13);
		add(peglbl14);
		add(peglbl15);
		add(clulbl9);
		add(clulbl10);
		
		add(colbtn1);
		add(colbtn2);
		add(colbtn3);
		add(colbtn4);
		add(colbtn5);
		add(colbtn6);
		
		peglbl1.setBackground(Color.DARK_GRAY);
		peglbl2.setBackground(Color.DARK_GRAY);
		peglbl3.setBackground(Color.DARK_GRAY);
		peglbl4.setBackground(Color.DARK_GRAY);
		peglbl5.setBackground(Color.DARK_GRAY);
		peglbl6.setBackground(Color.DARK_GRAY);
		peglbl7.setBackground(Color.DARK_GRAY);
		peglbl8.setBackground(Color.DARK_GRAY);
		peglbl9.setBackground(Color.DARK_GRAY);
		peglbl10.setBackground(Color.DARK_GRAY);
		peglbl11.setBackground(Color.DARK_GRAY);
		peglbl12.setBackground(Color.DARK_GRAY);
		peglbl13.setBackground(Color.DARK_GRAY);
		peglbl14.setBackground(Color.DARK_GRAY);
		peglbl15.setBackground(Color.DARK_GRAY);
		
		gnolbl1.setBackground(Color.LIGHT_GRAY);
		gnolbl2.setBackground(Color.LIGHT_GRAY);
		gnolbl3.setBackground(Color.LIGHT_GRAY);
		gnolbl4.setBackground(Color.LIGHT_GRAY);
		gnolbl5.setBackground(Color.LIGHT_GRAY);
		
		clulbl1.setBackground(Color.LIGHT_GRAY);
		clulbl2.setBackground(Color.LIGHT_GRAY);
		clulbl3.setBackground(Color.LIGHT_GRAY);
		clulbl4.setBackground(Color.LIGHT_GRAY);
		clulbl5.setBackground(Color.LIGHT_GRAY);
		clulbl6.setBackground(Color.LIGHT_GRAY);
		clulbl7.setBackground(Color.LIGHT_GRAY);
		clulbl8.setBackground(Color.LIGHT_GRAY);
		clulbl9.setBackground(Color.LIGHT_GRAY);
		clulbl10.setBackground(Color.LIGHT_GRAY);
		
		colbtn1.setLabel("Green");
		colbtn2.setLabel("Blue");
		colbtn3.setLabel("Red");
		colbtn4.setLabel("Yellow");
		colbtn5.setLabel("Orange");
		colbtn6.setLabel("Magenta");
	    	colbtn1.setBackground(Color.GREEN);
	    	colbtn2.setBackground(Color.BLUE);
	    	colbtn3.setBackground(Color.RED);
		colbtn4.setBackground(Color.YELLOW);
		colbtn5.setBackground(Color.ORANGE);
		colbtn6.setBackground(Color.MAGENTA);
		
	    
		add(winlbl);
		add(sclbl1);
		add(blbl2);	
		add(loselbl);	
		add(sclbl2);
		add(blbl4);	
		
		
		//add(slbl2);
		//add(slbl3);
		//add(slbl4);
			
    }//init
    
    public void start()
    {
       	double m;
		int k,a;
		secretCol=new int[3];
    	for(a=0;a<3;a++)
    	{
    		secretCol[a]=-1;
    		while(secretCol[a]<0)
    		{
    		m=Math.random();
    		k=(int) Math.floor((m*6)+1);
    		secretCol[a]=k;
    		}
        }
      
    for(a=0;a<3;a++)
    {
    	if(a==0)
    	{
    	if(secretCol[a]==1)
    	slbl2.setBackground(Color.GREEN);
    	else if(secretCol[a]==2)
    	slbl2.setBackground(Color.BLUE);
    	else if(secretCol[a]==3)
    	slbl2.setBackground(Color.RED);
    	else if(secretCol[a]==4)
    	slbl2.setBackground(Color.YELLOW);
    	else if(secretCol[a]==5)
    	slbl2.setBackground(Color.ORANGE);
    	else if(secretCol[a]==6)
    	slbl2.setBackground(Color.MAGENTA);
    }
    else if(a==1)
    {
    	if(secretCol[a]==1)
    	slbl3.setBackground(Color.GREEN);
    	else if(secretCol[a]==2)
    	slbl3.setBackground(Color.BLUE);
    	else if(secretCol[a]==3)
    	slbl3.setBackground(Color.RED);
    	else if(secretCol[a]==4)
    	slbl3.setBackground(Color.YELLOW);
    	else if(secretCol[a]==5)
    	slbl3.setBackground(Color.ORANGE);
    	else if(secretCol[a]==6)
    	slbl3.setBackground(Color.MAGENTA);
    }
    else if(a==2)
    {
    if(secretCol[a]==1)
    	slbl4.setBackground(Color.GREEN);
    	else if(secretCol[a]==2)
    	slbl4.setBackground(Color.BLUE);
    	else if(secretCol[a]==3)
    	slbl4.setBackground(Color.RED);
    	else if(secretCol[a]==4)
    	slbl4.setBackground(Color.YELLOW);
    	else if(secretCol[a]==5)
    	slbl4.setBackground(Color.ORANGE);
    	else if(secretCol[a]==6)
    	slbl4.setBackground(Color.MAGENTA);
    	}
	}
   	}//clrBoard	
    
    public void actionPerformed(ActionEvent ae)
    {
    	
     	int rightcp=0,rightcol=0;
    	int what=0;
 		
    	tri++;
    	if(ae.getSource()==colbtn1)
    	{
    		if(tri==1)
            peglbl1.setBackground(Color.GREEN);
            else if(tri==2)
            peglbl2.setBackground(Color.GREEN);
            else if(tri==3)
            peglbl3.setBackground(Color.GREEN);
       		else if(tri==4)
            peglbl4.setBackground(Color.GREEN);
            else if(tri==5)
            peglbl5.setBackground(Color.GREEN);
            else if(tri==6)
            peglbl6.setBackground(Color.GREEN);
            else if(tri==7)
            peglbl7.setBackground(Color.GREEN);
            else if(tri==8)
            peglbl8.setBackground(Color.GREEN);
            else if(tri==9)
            peglbl9.setBackground(Color.GREEN);
            else if(tri==10)
            peglbl10.setBackground(Color.GREEN);
            else if(tri==11)
            peglbl11.setBackground(Color.GREEN);
            else if(tri==12)
            peglbl12.setBackground(Color.GREEN);
            else if(tri==13)
            peglbl13.setBackground(Color.GREEN);
            else if(tri==14)
            peglbl14.setBackground(Color.GREEN);
            else if(tri==15)
            peglbl15.setBackground(Color.GREEN);
       		what=1;
    		}
   		else if(ae.getSource()==colbtn2)
    		{
    		
    		if(tri==1)
            peglbl1.setBackground(Color.BLUE);
            else if(tri==2)
            peglbl2.setBackground(Color.BLUE);
            else if(tri==3)
            peglbl3.setBackground(Color.BLUE);
       		else if(tri==4)
            peglbl4.setBackground(Color.BLUE);
            else if(tri==5)
            peglbl5.setBackground(Color.BLUE);
            else if(tri==6)
            peglbl6.setBackground(Color.BLUE);
            else if(tri==7)
            peglbl7.setBackground(Color.BLUE);
            else if(tri==8)
            peglbl8.setBackground(Color.BLUE);
            else if(tri==9)
            peglbl9.setBackground(Color.BLUE);
            else if(tri==10)
            peglbl10.setBackground(Color.BLUE);
            else if(tri==11)
            peglbl11.setBackground(Color.BLUE);
            else if(tri==12)
            peglbl12.setBackground(Color.BLUE);
            else if(tri==13)
            peglbl13.setBackground(Color.BLUE);
            else if(tri==14)
            peglbl14.setBackground(Color.BLUE);
            else if(tri==15)
            peglbl15.setBackground(Color.BLUE);
       		what=2;
    		}
    	else if(ae.getSource()==colbtn3)
    		{
    		if(tri==1)
            peglbl1.setBackground(Color.RED);
            else if(tri==2)
            peglbl2.setBackground(Color.RED);
            else if(tri==3)
            peglbl3.setBackground(Color.RED);
       		else if(tri==4)
            peglbl4.setBackground(Color.RED);
            else if(tri==5)
            peglbl5.setBackground(Color.RED);
            else if(tri==6)
            peglbl6.setBackground(Color.RED);
            else if(tri==7)
            peglbl7.setBackground(Color.RED);
            else if(tri==8)
            peglbl8.setBackground(Color.RED);
            else if(tri==9)
            peglbl9.setBackground(Color.RED);
            else if(tri==10)
            peglbl10.setBackground(Color.RED);
            else if(tri==11)
            peglbl11.setBackground(Color.RED);
            else if(tri==12)
            peglbl12.setBackground(Color.RED);
            else if(tri==13)
            peglbl13.setBackground(Color.RED);
            else if(tri==14)
            peglbl14.setBackground(Color.RED);
            else if(tri==15)
            peglbl15.setBackground(Color.RED);
            what=3;
    		}
    	else if(ae.getSource()==colbtn4)
    		{
    		if(tri==1)
            peglbl1.setBackground(Color.YELLOW);
            else if(tri==2)
            peglbl2.setBackground(Color.YELLOW);
            else if(tri==3)
            peglbl3.setBackground(Color.YELLOW);
       		else if(tri==4)
            peglbl4.setBackground(Color.YELLOW);
            else if(tri==5)
            peglbl5.setBackground(Color.YELLOW);
            else if(tri==6)
            peglbl6.setBackground(Color.YELLOW);
            else if(tri==7)
            peglbl7.setBackground(Color.YELLOW);
            else if(tri==8)
            peglbl8.setBackground(Color.YELLOW);
            else if(tri==9)
            peglbl9.setBackground(Color.YELLOW);
            else if(tri==10)
            peglbl10.setBackground(Color.YELLOW);
            else if(tri==11)
            peglbl11.setBackground(Color.YELLOW);
            else if(tri==12)
            peglbl12.setBackground(Color.YELLOW);
            else if(tri==13)
            peglbl13.setBackground(Color.YELLOW);
            else if(tri==14)
            peglbl14.setBackground(Color.YELLOW);
            else if (tri==15)
            peglbl15.setBackground(Color.YELLOW);
            what=4;
    		}
    	else if(ae.getSource()==colbtn5)
    		{
            if(tri==1)
            peglbl1.setBackground(Color.ORANGE);
            else if(tri==2)
            peglbl2.setBackground(Color.ORANGE);
            else if(tri==3)
            peglbl3.setBackground(Color.ORANGE);
       		else if(tri==4)
            peglbl4.setBackground(Color.ORANGE);
            else if(tri==5)
            peglbl5.setBackground(Color.ORANGE);
            else if(tri==6)
            peglbl6.setBackground(Color.ORANGE);
            else if(tri==7)
            peglbl7.setBackground(Color.ORANGE);
            else if(tri==8)
            peglbl8.setBackground(Color.ORANGE);
            else if(tri==9)
            peglbl9.setBackground(Color.ORANGE);
            else if(tri==10)
            peglbl10.setBackground(Color.ORANGE);
            else if(tri==11)
            peglbl11.setBackground(Color.ORANGE);
            else if(tri==12)
            peglbl12.setBackground(Color.ORANGE);
            else if(tri==13)
            peglbl13.setBackground(Color.ORANGE);
            else if(tri==14)
            peglbl14.setBackground(Color.ORANGE);
            else if(tri==15)
            peglbl15.setBackground(Color.ORANGE);
            what=5;
    		}
    	else if(ae.getSource()==colbtn6)
    		{
    		if(tri==1)
            peglbl1.setBackground(Color.MAGENTA);
            else if(tri==2)
            peglbl2.setBackground(Color.MAGENTA);
            else if(tri==3)
            peglbl3.setBackground(Color.MAGENTA);
       		else if(tri==4)
            peglbl4.setBackground(Color.MAGENTA);
            else if(tri==5)
            peglbl5.setBackground(Color.MAGENTA);
            else if(tri==6)
            peglbl6.setBackground(Color.MAGENTA);
            else if(tri==7)
            peglbl7.setBackground(Color.MAGENTA);
            else if(tri==8)
            peglbl8.setBackground(Color.MAGENTA);
            else if(tri==9)
            peglbl9.setBackground(Color.MAGENTA);
            else if(tri==10)
            peglbl10.setBackground(Color.MAGENTA);
            else if(tri==11)
            peglbl11.setBackground(Color.MAGENTA);
            else if(tri==12)
            peglbl12.setBackground(Color.MAGENTA);
            else if(tri==13)
            peglbl13.setBackground(Color.MAGENTA);
            else if(tri==14)
            peglbl14.setBackground(Color.MAGENTA);
            else if(tri==15)
            peglbl15.setBackground(Color.MAGENTA);
            what=6;
    	}
    	
    	ctr=ctr+1; 
    	pickCol[in++]=what;
    	
if(ctr==3)
{
 
for(w=0;w<3;w++)
copyy[w]=secretCol[w];
 
 for(w=0;w<3;w++)
{
	
	if(pickCol[w]==secretCol[w])
	{
	rightcp=rightcp+1;
	tapos[w]=pickCol[w];
	}
}

for(w=0;w<3;w++)
	for(x=0;x<3;x++)
		if(pickCol[w]==tapos[w])
		break;
		else if(w==x)
		continue;
		else if(pickCol[w]==tapos[x])
		continue;
		else if(pickCol[w]==copyy[x])
		{
			rightcol=rightcol+1;
			copyy[x]=-1;
			break;
		}


         if(set==1)
         {
         	if(rightcp==0)
         		clulbl1.setText("0");
         	else if(rightcp==1)
         		clulbl1.setText("1");
         	else if(rightcp==2)
         		clulbl1.setText("2");
         	else if(rightcp==3)
         		clulbl1.setText("3");
         	
         	if(rightcol==0)
         		clulbl2.setText("0");
         	else if(rightcol==1)
         		clulbl2.setText("1");
         	else if(rightcol==2)
         		clulbl2.setText("2");
         	else if(rightcol==3)
         		clulbl2.setText("3");
         pasaloadset=set; 	
         	if(rightcp==3 && set<=5)
         	{
         win++;
         sclbl1.setText(win+"");
         JOptionPane.showMessageDialog(null,"Congratulations you WIN!!!","Resulta",JOptionPane.INFORMATION_MESSAGE);
         set=0; 
     		}
         else if ((rightcp<3) && (set==5))
         {
    	set=0;
    	lose++;
    	sclbl2.setText(lose+"");
	    JOptionPane.showMessageDialog(null,"Sorry you LOSE.","Resulta",JOptionPane.INFORMATION_MESSAGE); 
	    }
		pasaloadcp=rightcp;
      	rightcp=0;
        rightcol=0;
        in=0;
        ctr=0;
        tapos[0]=-1;
        tapos[1]=-1;
        tapos[2]=-1;  	
         }
         else if(set==2)
         {
         	if(rightcp==0)
         		clulbl3.setText("0");
         	else if(rightcp==1)
         		clulbl3.setText("1");
         	else if(rightcp==2)
         		clulbl3.setText("2");
         	else if(rightcp==3)
         		clulbl3.setText("3");
         	
         	if(rightcol==0)
         		clulbl4.setText("0");
         	else if(rightcol==1)
         		clulbl4.setText("1");
         	else if(rightcol==2)
         		clulbl4.setText("2");
         	else if(rightcol==3)
         		clulbl4.setText("3");
         	pasaloadset=set;
        if(rightcp==3 && set<=5)
        {
         set=0;
         win++;
         sclbl1.setText(win+"");
         JOptionPane.showMessageDialog(null,"Congratulations you WIN!!!","Resulta",JOptionPane.INFORMATION_MESSAGE);
        } 
        
         else if ((rightcp<3) && (set==5))
         {
         set=0;
         lose++;
         sclbl2.setText(lose+"");
         JOptionPane.showMessageDialog(null,"Sorry you LOSE.","Resulta",JOptionPane.INFORMATION_MESSAGE); 
                 
         }
         pasaloadcp=rightcp;
      	 rightcp=0;
         rightcol=0;
         in=0;
         ctr=0;
         tapos[0]=-1;
         tapos[1]=-1;
         tapos[2]=-1;  	
                  
         }
         else if(set==3)
         {
         	if(rightcp==0)
         		clulbl5.setText("0");
         	else if(rightcp==1)
         		clulbl5.setText("1");
         	else if(rightcp==2)
         		clulbl5.setText("2");
         	else if(rightcp==3)
         		clulbl5.setText("3");
         	
         	if(rightcol==0)
         		clulbl6.setText("0");
         	else if(rightcol==1)
         		clulbl6.setText("1");
         	else if(rightcol==2)
         		clulbl6.setText("2");
         	else if(rightcol==3)
         		clulbl6.setText("3");
         pasaloadset=set;
         if(rightcp==3 && set<=5)
         	{
         	win++;
         	sclbl1.setText(win+"");
         	JOptionPane.showMessageDialog(null,"Congratulations you WIN!!!","Resulta",JOptionPane.INFORMATION_MESSAGE);
         	set=0;
       	
         	}
         else if ((rightcp<3) && (set==5))
         	{
	        lose++;
    	    sclbl2.setText(lose+"");
        	JOptionPane.showMessageDialog(null,"Sorry you LOSE.","Resulta",JOptionPane.INFORMATION_MESSAGE); 
    		set=0;
    	 	}
    		pasaloadcp=rightcp;
      	   	rightcp=0;
         	rightcol=0;
         	in=0;
         	ctr=0;
         	tapos[0]=-1;
	tapos[1]=-1;
	tapos[2]=-1;  	
         	}
         else if(set==4)
         {
         	if(rightcp==0)
         		clulbl7.setText("0");
         	else if(rightcp==1)
         		clulbl7.setText("1");
         	else if(rightcp==2)
         		clulbl7.setText("2");
         	else if(rightcp==3)
         		clulbl7.setText("3");
         	
         	if(rightcol==0)
         		clulbl8.setText("0");
         	else if(rightcol==1)
         		clulbl8.setText("1");
         	else if(rightcol==2)
         		clulbl8.setText("2");
         	else if(rightcol==3)
         		clulbl8.setText("3");
         	
         	pasaloadset=set;
         	if(rightcp==3 && set<=5)
         	{
         	win++;
         	sclbl1.setText(win+"");
         	JOptionPane.showMessageDialog(null,"Congratulations you WIN!!!","Resulta",JOptionPane.INFORMATION_MESSAGE);
         	set=0;
  	         }
         else if ((rightcp<3) && (set==5))
         	{
    	     lose++;
        	 sclbl2.setText(lose+"");
         	 JOptionPane.showMessageDialog(null,"Sorry you LOSE.","Resulta",JOptionPane.INFORMATION_MESSAGE); 
         	 set=0;
         	}
    
         	pasaloadcp=rightcp;
      		rightcp=0;
         	rightcol=0;
         	in=0;
         	ctr=0;
         	tapos[0]=-1;
	tapos[1]=-1;
	tapos[2]=-1;  	
           }
         else if(set==5)
           {
         	if(rightcp==0)
         		clulbl9.setText("0");
         	else if(rightcp==1)
         		clulbl9.setText("1");
         	else if(rightcp==2)
         		clulbl9.setText("2");
         	else if(rightcp==3)
         		clulbl9.setText("3");
         	
         	if(rightcol==0)
         		clulbl10.setText("0");
         	else if(rightcol==1)
         		clulbl10.setText("1");
         	else if(rightcol==2)
         		clulbl10.setText("2");
         	else if(rightcol==3)
         		clulbl10.setText("3");
         	
         	pasaloadset=set;
         	if(rightcp==3 && set<=5)
         	{
          	win++;
          	sclbl1.setText(win+"");
          	JOptionPane.showMessageDialog(null,"Congratulations you WIN!!!","Resulta",JOptionPane.INFORMATION_MESSAGE);
          	set=0;
                
        	}
         else if ((rightcp<3) && (set==5))
         	{
    		lose++;
    		sclbl2.setText(lose+"");
         	JOptionPane.showMessageDialog(null,"Sorry you LOSE.","Resulta",JOptionPane.INFORMATION_MESSAGE); 
    		set=0;
    		}
      		pasaloadcp=rightcp;
      		rightcp=0;
         	rightcol=0;
         	in=0;
         	ctr=0;
         	tapos[0]=-1;
	tapos[1]=-1;
	tapos[2]=-1;  	
           }
        
 		if(pasaloadcp==3 && pasaloadset<=5)
 		{
 		  /*******************************/
		int intAns =JOptionPane.showConfirmDialog
		(null, "Play Again?","Confirmation", JOptionPane.YES_NO_OPTION);
		if (intAns == JOptionPane.YES_OPTION)
		{
		;
		}	
		else
		{
		JOptionPane.showMessageDialog(null,"THANK YOU","",JOptionPane.INFORMATION_MESSAGE);
		System.exit(0);
		}
		/***************************/
		}
        else if(pasaloadcp<3 && pasaloadset==5)      
        {
         /*******************************/
		int intAns =JOptionPane.showConfirmDialog
		(null, "Play Again?","Confirmation", JOptionPane.YES_NO_OPTION);
		if (intAns == JOptionPane.YES_OPTION)
		;	
		else
		{
		 JOptionPane.showMessageDialog(null,"Thank You!!!","",JOptionPane.INFORMATION_MESSAGE);
		System.exit(0);
		}
		/***************************/
    	}
          set=set+1;
      }//if
   }//class
    
}//class

Does your program compile ?? I dont think so because I didnt see any DARK_GRAY and LIGHT_GRAY colors in the color class ... they were darkGray and lightGray.. ??

Does your program compile ?? I dont think so because I didnt see any DARK_GRAY and LIGHT_GRAY colors in the color class ... they were darkGray and lightGray.. ??

yes my program compiles with no errors on it, this is 100% sure. i have tested it and its working with the only problem that i cant repeat it, u will notice from the bottom part of this program the statement that i have mentioned to execute is a ; character because i dont know what to place there once Yes button is pressed.

It's not even compiling in my compiler ... I use JBuilder7 with jdk 1.4 ... ?? which compiler do you use to compile?

It's not even compiling in my compiler ... I use JBuilder7 with jdk 1.4 ... ?? which compiler do you use to compile?

its jdk 1.4.2

psylocke... you should really learn to program more modularly & object-orientated-ly. If you had, making little modifications to your program (and controlling the flow of the program) would be much easier.

But as it looks now... I think you should switch your program to the following structure:

  • a create() method in which you 'create' everything (all the new labels etc.)
  • a reset() method in which you set all values, fields, label names, guesses etc. to their initial (pre-game) values
  • a start() method (same as you already have)

Then get your YES button ActionListener to call only the init() method and then the start() method.

oops, couldn't edit my post.

Ignore the last bit. So, basically.. you get your applet's init() method to call all three above-mentioned methods. And get your YES button ActionListener to call the reset() and start() methods only.

Since everything here appears to be in one method, I get the impression that psylocke is brand new to Java and hasn't yet learned how to create multiple methods and classes. Am I right?

psylocke,

Another suggestion: Since you have so many related variables (i.e. Label peglbl1, peglbl2, peglbl3) it may make your code neater if you used arrays.

Instead of multiple Label statements, do this:

Label[] pegLabel = new Label[15];

for (int i = 0; i < pegLabel.length; i++) {
    pegLabel[i] = new Label("");
    pegLabel.setBackground(Color.DARK_GRAY);
    add(pegLabel[i])
}

// - or if you have a string table 'pegStrings' with all the initial
// strings of the labels, you could do this:
for (int i = 0; i < pegLabel.length; i++)
   pegLabel[i] = new Label(pegStrings[i]);

Then instead of what you do in your action listener

if(tri==1)
peglbl1.setBackground(Color.GREEN);
else if(tri==2)
peglbl2.setBackground(Color.GREEN);
else if(tri==3)
peglbl3.setBackground(Color.GREEN);

You can do this:

pegLabel[tri].setBackground(Color.GREEN);

Let us know if this makes sense. I'm not sure what you have learned. Definitely give arrays a try. It should tidy up your code much.


Ed

hi cosi, thanks for the big help. i really know that there is a way to make this short using arrays but i dont know how to do that i cant find reference material for this during that time, coz i was in a rush doing this project. your recommendations are all great this exactly what i also wanted to know...THANK U so much cosi. muah

apcxpc,

thanks for the answers, thanks a lot...thats all i can say right now. thanks for the help really.

Since everything here appears to be in one method, I get the impression that psylocke is brand new to Java and hasn't yet learned how to create multiple methods and classes. Am I right?

yah thats right...but i know i can be good in java in time, it will be because of this group and my eagerness to learn the language.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.