Drawing an attributed string in Swing

Main.java:

import java.awt.event.*;
import java.awt.geom.*;
import java.awt.font.*;
import javax.swing.*;
import java.text.*;
import java.awt.*;
 
public class Main extends JFrame {
   private Image img;
  
   public Main() {
      addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent we) {
            System.exit(1);
         }
      }); 
 
      img = new javax.swing.ImageIcon("per.gif").getImage(); 
   }
 
   public void paint(Graphics g) {
      Graphics2D g2d = (Graphics2D) g;
  
      String text = "90% of all statistics are made up!";
 
      Font font = new Font("Serif", Font.PLAIN, 24);
      AttributedString as = new AttributedString(text);
      as.addAttribute(TextAttribute.FONT, font, 0, 11);
 
      // image in between the text
      ImageGraphicAttribute iga = new ImageGraphicAttribute(img, (int) 
                                               GraphicAttribute.TOP_ALIGNMENT);
      as.addAttribute(TextAttribute.CHAR_REPLACEMENT, iga, 2, 3);
 
      // shape in between the text
      Shape s1 = new Rectangle2D.Double(10, 0, 5, 15);
      Shape s2 = new Rectangle2D.Double(10, 18, 5, 5);
      Area a1 = new Area(s1);
      Area a2 = new Area(s2);
      a1.add(a2);
      ShapeGraphicAttribute sga = new ShapeGraphicAttribute(a1,
                                               GraphicAttribute.TOP_ALIGNMENT, false);
      as.addAttribute(TextAttribute.CHAR_REPLACEMENT, sga, 33, 34);
 
      // set the background of the first 3 characters to red
      as.addAttribute(TextAttribute.BACKGROUND, Color.red, 0, 3);
 
      // set the foreground of the word "are" to blue
      as.addAttribute(TextAttribute.FOREGROUND, Color.blue, 22, 25);
 
      // underline the word "all"
      as.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON, 7, 10);
 
      // change fontsize and weight for word "statistics"
      as.addAttribute(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD, 11, 21);
      as.addAttribute(TextAttribute.SIZE, new Float(14f), 11, 21);
 
      // make the words "made up" italic
      as.addAttribute(TextAttribute.POSTURE,TextAttribute.POSTURE_OBLIQUE,25,text.length());
 
      g2d.drawString(as.getIterator(), 20, 100);
   }
   
   public static void main(String []args) {
      Main main = new Main();
      main.setSize(420, 200);
      main.setVisible(true);
   }
}

Image used: