Κώδικας: Σχεδίαση κειμένου

import javax.swing.JFrame;
import javax.swing.JComponent;

import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.Font;

public class TextDemo {
    class GraphicPane extends JComponent {
        public GraphicPane() {
            super();
        }
    
        @Override public void paint(Graphics g) {
            g.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 14));
            g.drawString("Hello, World!", 30, 30);
        }
    }
    
    public TextDemo() {
        JFrame jf = new JFrame("Hello, World!");
        GraphicPane gp = new GraphicPane();
        
        jf.setBounds(0,0, 800, 600);
        jf.setLayout(new BorderLayout());        
        jf.add(gp, BorderLayout.CENTER);
        
        // Remember, the method show() is deprecated
        jf.setVisible(true);
    }

    public static void main(String[] args) {
        new TextDemo();
    }
}