Display vertical textTag(s): AWT
import java.applet.*; import java.awt.*; public class verticalText extends Applet { String s = "Vertical text"; int x=10; int y=10; int v; public void init() {} public void paint(Graphics g) { v=g.getFontMetrics(getFont()).getHeight()+1; System.out.println(v); int j =0; int k= s.length(); while(j < k+1) { if (j == k) g.drawString(s.substring(j),x, y+(j*v)); else g.drawString(s.substring(j,j+1),x, y+(j*v)); j++; } } }
import java.awt.geom.AffineTransform; import java.awt.Graphics2D; public void paint(Graphics g){ Graphics2D g2d = (Graphics2D)g; // clockwise 90 degrees AffineTransform at = new AffineTransform(); // thanks to M.C. Henle for the bug fix! at.setToRotation(-Math.PI/2.0, width/2.0, height/2.0); g2d.setTransform(at); g2d.drawString("Vertical text", x, y); }
mail_outline
Send comment, question or suggestion to howto@rgagnon.com
Send comment, question or suggestion to howto@rgagnon.com