请教一下,比如说一个panel上正常的文字显示,逆时针旋转90度,如何用代码实现。谢谢。

解决方案 »

  1.   

    import javax.swing.*;
    import java.awt.*;
    public class test {
    public static void main(String[] args)
    {
    JFrame frm = new JFrame();
    frm.setSize(300, 400);
    frm.add(new JPanel(){
    public void paintComponent(Graphics g)
    {
     super.paintComponent(g);
     Graphics2D g2 = (Graphics2D)g;
     g2.rotate(-Math.PI/2,100, 100);
     g2.drawString("hello, world",100, 100);
    }
    });
    frm.setVisible(true);
    }
    }