我有一个数字数组,对应于我手动添加的不同值,但似乎找不到为数字分配不同深浅颜色的方法。这就是我所得到的:
private void givecolor() {
int[] colorarray = new int[6];
int assignedvalue = 40;
for (int index = 0; i < colorarray.length; i++){
colorarray[i] = assignedvalue;
assignedvalue--;
}
for (int i = 0; i < colorarray.length; i++){
colorarray = Color.getGreen;
}
}发布于 2020-11-22 05:07:51
我不认为这段代码会为你编译。无论如何,您需要将颜色设置为colorarray上的特定索引。
colorarray[i] = Color.green;此外,第二个for循环将该数组的所有值指定为绿色。
https://stackoverflow.com/questions/64948028
复制相似问题