<%@ page import="java.util.*" %>
<%!
public ArrayList getRandomHexColor(int colorCount) throws Exception
{
ArrayList colorList = new ArrayList(colorCount);
try
{
Random random = new Random(0L);//pseudorandom number generator
for(int i=0;i<colorCount;i++)
{
random.nextFloat();//the next pseudorandom
int colorR = Math.round(255-random.nextFloat()*255);
int colorG = Math.round(255-random.nextFloat()*255);
int colorB = Math.round(random.nextFloat()*255);
//hex color string
String color = parseString(colorR)+parseString(colorG)+parseString(colorB);
if(!colorList.contains(color))
{
colorList.add(color);
}
else
{
colorCount+=1;
}
}//end for
}
catch(Exception ex)
{
throw ex;
}
return colorList;
}
public String parseString(int data)
{
String str = Integer.toHexString(data);
if(str.length()==1)
{
str = "0"+str;
}
return str;
}
%>
<%
//Use pseudorandom number generator
out.println("<table border=0 align='left'>");
ArrayList colorAryList = getRandomHexColor(100);
for(int i=0,j=colorAryList.size();i<j;i++)
{
String color = "#"+(String)colorAryList.get(i);
if(i%8==0)
out.println("<tr>");
out.println("<td bgcolor=/"#"+color+"/">Mode"+(i+1)+" : "+color+"<td>");
}
out.println("</table>");
%>