Witam serdecznie,
mam następujący problem. Wyskakuje mi na konsoli:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Color parameter outside of expected range: Red Green Blue
Dane przekazywane do zmiennej z klasy Color są w przedziale 0-255... co mogło pujść nie tak?
Poniżej większa cześć klasy. Konstruktor jest wywoływany przez AncesorListenera z JTextArea.
import java.awt.Color;
/**
*
* @author E5410
*/
public class SetFontParam {
private static String type = "Dialog";
private static int size = 16;
private static int backgroundColorR;
private static int fontColorR;
private static int backgroundColorG;
private static int fontColorG;
private static int backgroundColorB;
private static int fontColorB;
private static String[] allOfParam;
private static Color fontColor = null;
private static Color backgroundColor = null;
public SetFontParam(String s) {
allOfParam = s.split(" ");
if (allOfParam.length == 8) {
setType(allOfParam[0]);
setSize(allOfParam[1]);
setBackgroundColorR(allOfParam[2]);
setBackgroundColorG(allOfParam[3]);
setBackgroundColorB(allOfParam[4]);
setFontColorR(allOfParam[5]);
setFontColorG(allOfParam[6]);
setFontColorB(allOfParam[7]);
fontColor = new Color(getFontColorR(), getFontColorG(), getFontColorB());
backgroundColor = new Color(getBackgroundColorR(), getBackgroundColorG(), getBackgroundColorB());
}
}
public static void setType(String type) {
SetFontParam.type = type;
}
public static String getType() {
return type;
}
public static void setSize(String size) {
SetFontParam.size = 16;
}
public static int getSize() {
return size;
}
public static int getBackgroundColorR() {
return backgroundColorR;
}
public static void setBackgroundColorR(String backgroundColorR) {
SetFontParam.backgroundColorR = Integer.parseInt(backgroundColorR);
}
public static int getFontColorR() {
return fontColorR;
}
public static void setFontColorR(String fontColorR) {
SetFontParam.fontColorR = Integer.parseInt(fontColorR);
}
public static int getBackgroundColorG() {
return backgroundColorG;
}
public static void setBackgroundColorG(String backgroundColorG) {
SetFontParam.backgroundColorG = Integer.parseInt(backgroundColorG);
}
public static int getFontColorG() {
return fontColorG;
}
public static void setFontColorG(String fontColorG) {
SetFontParam.fontColorG = Integer.parseInt(fontColorG);
}
public static int getBackgroundColorB() {
return backgroundColorB;
}
public static void setBackgroundColorB(String backgroundColorB) {
SetFontParam.backgroundColorB = Integer.parseInt(backgroundColorB);
}
public static float getFontColorB() {
return fontColorB;
}
public static void setFontColorB(String fontColorB) {
SetFontParam.fontColorB = Integer.parseInt(fontColorB);
}
public static Color getFontColor() {
return fontColor;
}
public static Color getBackgroundColor() {
return backgroundColor;
}
}