Rotating text in Swing

You could apply AffineTransform on the graphics context directly or you can use the TextLayout class as shown here.

Main.java:

import java.awt.image.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.awt.font.*;
import javax.swing.*;
import java.awt.*;
 
public class Main extends JFrame {
   private int degrees = 0;
 
   public Main() {
      addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent we) {
            System.exit(1);
         }
      });
 
      JButton button = new JButton("Rotate 10 degrees");
      button.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent ae) {
            degrees += 10;
            repaint();
         }
      });
 
      getContentPane().setLayout(new BorderLayout());
      getContentPane().add(BorderLayout.SOUTH, button);
   }
 
   public void paint(Graphics g) {
      super.paint(g);
 
      Graphics2D g2d = (Graphics2D) g;
 
      g2d.drawString("Java and...", 80, 50);
     
      double radians = degrees * (Math.PI / 180);
      AffineTransform at = new AffineTransform();
      at.setToRotation(radians);
 
      FontRenderContext frc = g2d.getFontRenderContext();
      Font font = new Font("Times", Font.PLAIN, 20);
      Font derivedFont = font.deriveFont(at);
      TextLayout textLayout = new TextLayout("Alicia", derivedFont, frc);
      textLayout.draw(g2d, getSize().width/2, getSize().height/2);
 
      g2d.drawString("all I need ;)", 330, 180);
   }
  
   public static void main(String []args) {
      Main main = new Main();
      main.setSize(480, 240);
      main.setVisible(true);
   }
}