如标题,JTextField txtBarCode=new JTextField(10);让它怎样垂直?那位大虾知道,请指教?

解决方案 »

  1.   

    请用  textArea 代替  设置输入字符的最大长度
      

  2.   

    qianwu1984,YeLang2007谢谢你们的回帖。
    qianwu1984的方法我试了,不太好用,那么用文本框的文字还是竖直的,不能够旋转90度。
      

  3.   

    我重写了public void paintComponent(Graphics g)方法。
        /**
        冲写paintComonent方法。
         **/
        @Override
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D) g;
            //取得坐标
            AffineTransform at = g2.getTransform();
            //旋转角度
            if (or == null) {
                at.rotate(theta);
            } else {
                at.rotate(theta, or.x, or.y);
            }
            //设置绘制坐标到组件
            g2.setTransform(at);
    //        g2.drawString(txtContent, txtP.x, txtP.y-20);
            g2.setFont(new Font(null, Font.PLAIN, 20));
            g2.drawString(txtContent, txtP.x, txtP.y + 20);
        }
    哈哈!只能这么办了。