import javax.swing.*;
import java.awt.*;
import java.awt.geom.AffineTransform;

public class String04 extends JFrame {

    public String04() {
        setLayout( new BorderLayout());
        setTitle("Draw Vertical Text Demo");
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setSize(400, 400);
        this.getContentPane().add(new CCanvas(), BorderLayout.CENTER );
    }

    public static void main(String[] args) {
        String04 frame = new String04();
        frame.setVisible(true);
    }
}


class CCanvas extends JPanel {
    @Override
    public void paint(Graphics g) {
        Graphics2D g2 = (Graphics2D) g;

        //
        // Define rendering hint, font name, font style and font size
        //
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);
        g2.setFont(new Font(Font.SERIF, Font.BOLD, 20));

        //
        // Rotate 90 degree to make a vertical text
        //
        AffineTransform at = new AffineTransform();
        at.setToRotation(Math.toRadians(-90), 50, 200);
        g2.setTransform(at);
        g2.drawString("This is a vertical text", 50, 200);
    }

  
}
