【问题标题】:Rotate a Unicode character by 90 degree将 Unicode 字符旋转 90 度
【发布时间】:2018-07-18 14:01:23
【问题描述】:

问题很简单。我需要使用向上的 Unicode 字符 »,即如果您将 » 逆时针旋转 90 度。

请帮助我如何旋转或在哪里可以找到 Unicode 中的符号。从昨天开始我就一直在找。

或者可能是符号>> 向上。

我在 JButtonswing 中使用它。如果我能找到如何在该按钮上旋转此文本/按钮,那也可以。

【问题讨论】:

  • 嗯,你可以使用this 之类的东西来旋转角色,但这会产生图像,但不确定这是否适合你
  • 怎么样?我刚去fileformat.info/info/unicode/char/search.htm 并搜索“向上”,然后是“箭头”,然后是“双”并找到它。
  • @yshavit 感谢您的帮助。关闭了。但在我的项目中,我一直在使用像 >> 这样的符号,其中 的风格似乎有点不同。有没有类似>> 的东西??
  • 根据@MadProgrammer 的建议,您可以在 BufferedImage 上进行绘制,一旦获得图像,您只需创建一个 ImageIcon 并将其添加到按钮中。或者,如果您想要一些可重用的类,您可以 1) 创建一个 Text Icon,然后 2) 使用 Rotated Icon 为您的按钮创建图标。
  • 我粘贴了上面的链接。在它呈现给您的搜索字段中,搜索我提到的最后一个词“double”。然后滚动直到找到它,或者只是在页面内搜索︽。向下版本也在那里。并注意它是如何标记为“垂直左双角括号”的?这表明如果您在该字段中仅搜索“ANGLE BRACKET”,则可能存在单一版本。 (顺便说一句,这些都只是基本的搜索技能,但这些技能对于当今时代的编程非常重要!)

标签: java swing unicode


【解决方案1】:

如果您的按钮上有其他字符,这会更复杂,但这里有一个简单的示例,说明如何覆盖 JButton 的 paintComponent 方法并旋转图形。

public class UITest
{
    public static void main(String a[]) throws ParseException
    {
        JFrame frame = new JFrame();
        JPanel panel = new JPanel();
        JButton button = new JButton(){
            @Override
            protected void paintComponent(Graphics g)
            {
                super.paintComponent(g);
                Graphics2D g2d = ((Graphics2D)g);

                // rotate the graphics
                AffineTransform oldTransform = g2d.getTransform();
                AffineTransform newTransform = AffineTransform.getRotateInstance(Math.toRadians(270));
                g2d.setTransform(newTransform);

                g2d.drawString("»", -17, 17);
                g2d.setTransform(oldTransform);
            }
        };
        button.setPreferredSize(new Dimension(30, 30));

        panel.add(button);
        frame.setContentPane(panel);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
    }
}

【讨论】:

    【解决方案2】:

    您也可以尝试使用https://shapecatcher.com/index.html工具搜索看起来像旋转>>的unicodes

    Buginese letter ra: ᨑ
    

    看起来最合适

    【讨论】:

      猜你喜欢
      • 2011-03-22
      • 1970-01-01
      • 2015-03-22
      • 2022-01-13
      • 2011-09-24
      • 2020-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多