The following code should create a 3D rectangle image with text. The problem is there doesn’t seem to be any difference between the 3D rectangle raised (true) and not raised (false). Is there something I need to do to get a 3D effect or does it simply not work?


Thanks,

Robin

**************

package jservlets;

import java.io.*;
import java.util.*;
import java.sql.*;

import javax.servlet.*;
import javax.servlet.http.*;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;


public class CreateRectangleTest extends HttpServlet
{
PrintWriter out;
PrintWriter err;


private void CreateButton(HttpServletRequest request, HttpServletResponse response) throws IOException
{
try
{
out.println ("\n\n+++++ CreateButton Process +++++\n");
out.println("<P>");

int width = 250;
int height = 250;

// Constructs a BufferedImage of one of the predefined image types.
BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);

// Create a graphics which can be used to draw into the buffered image
Graphics2D g2d = bufferedImage.createGraphics();

// create a rectangle with black
g2d.setColor(Color.black);

//this will draw a filled 3-D rectangle of width 100 & height 50 at (10,10)

g2d.fill3DRect(10,10,100,50,true);

g2d.setColor(Color.yellow);
g2d.setFont(new Font( "Arial", Font.BOLD, 15 ));

//create a string with yellow
g2d.drawString("About Us", 20, 45);

// Disposes of this graphics context and releases any system resources that it is using.
g2d.dispose();

// Save as PNG
File file = new File("myimage.png");
ImageIO.write(bufferedImage, "png", file);

// Save as GIF
file = new File("myimage.gif");
ImageIO.write(bufferedImage, "gif", file);

}

catch (IOException sqlio)
{

out.println("IOException: Could not execute Create Button.");
err.println (sqlio.getMessage () ) ;
}



}


public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{

try
{
response.setContentType("text/html");

out = response.getWriter();
err = response.getWriter();

CreateButton(request, response);

out.println("</body></html>");
out.close();


}

catch (IOException io)
{
err.println (io.getMessage () ) ;
}

catch(Throwable io)
{
io.printStackTrace();
}



}

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
doPost(request, response);
}

}