Just create a new color using your values. I added the line of code into your try statement.
try
{
red = Integer.parseInt(redText.getText());
green = Integer.parseInt(greenText.getText());
blue = Integer.parseInt(blueText.getText());
if(red > 255 || red < 0 || green > 255 || green < 0 || blue > 255 || blue < 0)
{
JOptionPane.showMessageDialog(null, "Please enter a number between 0 and 255!");
redText.setText("0");
blueText.setText("0");
greenText.setText("0");
}
else
{
//creates a new color using the values inputed by the user
Color colorTest = new Color(red,green,blue);
color = "" + red + green + blue;
JOptionPane.showMessageDialog(null, color);
//sets the color to the one created from user inputted values
centerPanel.setBackground(colorTest);
}
}
Last edited by jasimp; Oct 29th, 2008 at 9:24 pm.
Reputation Points: 533
Solved Threads: 53
Senior Poster
Offline 3,593 posts
since Aug 2007