List of usage examples for java.awt.font ImageGraphicAttribute ImageGraphicAttribute
public ImageGraphicAttribute(Image image, int alignment)
From source file:MainClass.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Font serifFont = new Font("Serif", Font.PLAIN, 32); AttributedString as = new AttributedString("www.java2s.com"); as.addAttribute(TextAttribute.FONT, serifFont); Image image = createImage();/*from ww w.java 2 s. com*/ ImageGraphicAttribute imageAttribute = new ImageGraphicAttribute(image, GraphicAttribute.TOP_ALIGNMENT); as.addAttribute(TextAttribute.CHAR_REPLACEMENT, imageAttribute, 5, 6); g2.drawString(as.getIterator(), 20, 120); }