Skip to main content
Known Participant
July 6, 2007
Answered

How to the custom color in the Java object?

  • July 6, 2007
  • 2 replies
  • 498 views
My code:
<cfset var image = createObject("java","java.awt.image.BufferedImage") />
<cfset var color=createObject("java","java.awt.Color") />
<cfset g = image.getGraphics() />
<cfset g.setColor(color.white) />

In the last row,I want to repalce the "color.white" with #F23ABB,How???
Thanks.
This topic has been closed for replies.
Correct answer cf_dev2
Try the decode() method and you must initialize the BufferedImage object before using it.
http://java.sun.com/j2se/1.4.2/docs/api/java/awt/image/BufferedImage.html#BufferedImage(int,%20int,%20int)

<cfset var bi = createObject("java","java.awt.image.BufferedImage") />
<cfset var image = bi.init(theImageWidth, theImageHeight, bi.TYPE_INT_ARGB) />
<cfset var g = image.getGraphics() />
<cfset var color = createObject("java","java.awt.Color") />
<cfset g.setColor(Color.decode("##F23ABB")) />

2 replies

FlashcqxgAuthor
Known Participant
July 6, 2007
thanks,it works.
cf_dev2Correct answer
Inspiring
July 6, 2007
Try the decode() method and you must initialize the BufferedImage object before using it.
http://java.sun.com/j2se/1.4.2/docs/api/java/awt/image/BufferedImage.html#BufferedImage(int,%20int,%20int)

<cfset var bi = createObject("java","java.awt.image.BufferedImage") />
<cfset var image = bi.init(theImageWidth, theImageHeight, bi.TYPE_INT_ARGB) />
<cfset var g = image.getGraphics() />
<cfset var color = createObject("java","java.awt.Color") />
<cfset g.setColor(Color.decode("##F23ABB")) />