I am trying to change the color of a Jbutton depending on values in an array. This method reads an array and try to changes the color of a button depending on the value in the aray. My problem is that that setForeground() does not seem to be working. Just for kicks I tried setText() and it works fine. I am running this method is a seprate thread so the GUI is not locking up.
public void playSequance()
{
int[] tempArray = new int[100];
tempArray = test.sequance();
for(int i=0; i<tempArray.length; i++)
{
if (tempArray[i] == 1)
{
System.out.println("a red button was detected");
greenButton.setText("some text is on the button now");//this works
// trying to change the color here from red to white. this does not work.
redButton.setForeground(Color.white);
//test.redSound();//play a beep, got anoying after several 100 tests, so commented out
try{Thread.sleep(500);}catch(InterruptedException E) {}//pause in between beeps
}
if (tempArray[i] == 2)
{
//same code here but for a different button
}
}
}//end playsequance()
any ideas?