Answer Posted / sagar
Try to use this code it may help you
public class MessageImage {
/** Creates an Image of a string with an oblique
* shadow behind it. Used by the ShadowedText servlet
* and the ShadowedTextFrame desktop application.
*/
public static Image makeMessageImage(String message,
String fontName,
int fontSize) {
Frame f = new Frame();
// Connect to native screen resource for image creation.
f.addNotify();
// Make sure Java knows about local font names.
GraphicsEnvironment env =
GraphicsEnvironment.getLocalGraphicsEnvironment();
env.getAvailableFontFamilyNames();
Font font = new Font(fontName, Font.PLAIN, fontSize);
FontMetrics metrics = f.getFontMetrics(font);
int messageWidth = metrics.stringWidth(message);
int baselineX = messageWidth/10;
int width = messageWidth+2*(baselineX + fontSize);
int height = fontSize*7/2;
int baselineY = height*8/10;
Image messageImage = f.createImage(width, height);
Graphics2D g2d =
(Graphics2D)messageImage.getGraphics();
g2d.setFont(font);
g2d.translate(baselineX, baselineY);
g2d.setPaint(Color.lightGray);
AffineTransform origTransform = g2d.getTransform();
g2d.shear(-0.95, 0);
g2d.scale(1, 3);
g2d.drawString(message, 0, 0);
g2d.setTransform(origTransform);
g2d.setPaint(Color.black);
g2d.drawString(message, 0, 0);
return(messageImage);
}
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is the difference between get and post methods?
Which protocol will be used by browser and servlet to communicate
What is the use of httpservletresponsewrapper?
Differentiate between get and post?
Tell the new features added in servletrequest interface i.e. Servlet 2.4
What is the difference between 2 types of servlets?
What is servlet configuration?
What do you mean by session tracking and also explain its techniques?
What do you mean by mime type?
What are the functions of an intercepting filter?
Describe the phases of servlet lifecycle?
How we can call a jsp from the servlet?
How can we include static files in the jsp page?
Is servlet thread safe?
Is dispatcher servlet a singleton?