3

Question is very simple. I need to use an Unicode character » which is upwards i.e. if you rotate the » anticlockwise by 90 degree.

Please help me how to rotate or where I can find that symbol in Unicode. I've been trying to find since yesterday.

Or may be symbol >> in upwards.

I am using this in a JButton in swing. If I can find how to rotate this text/button on that button that will also work.

  • 3
    Well, you could use something like [this](https://stackoverflow.com/questions/10083913/how-to-rotate-text-with-graphics2d-in-java) to rotate the character, but that would then result in an image, but not sure if that works for you – MadProgrammer Feb 08 '18 at 05:20
  • 3
    How about `︽`? I just went to https://www.fileformat.info/info/unicode/char/search.htm and searched for "up," then "arrow," then "double" and found it. – yshavit Feb 08 '18 at 05:21
  • @yshavit Thanks for the help. It's close. But in my project I've been using symbols like `>>` where `︽` style seems to be a bit different. Is there something available like `>>` ?? –  Feb 08 '18 at 05:25
  • Following up on @MadProgrammer suggestion, you can paint onto a BufferedImage and once you have the image, you just create an ImageIcon and add it to the button. Or if you want some reusable classes you could 1) Create a [Text Icon](https://tips4java.wordpress.com/2009/04/02/text-icon/) and then 2) use the [Rotated Icon](https://tips4java.wordpress.com/2009/04/06/rotated-icon/) to create the Icon for your button. – camickr Feb 08 '18 at 05:25
  • @MadProgrammer Thanks for your help. I really appreciate it and also camikr. I will go for that option as last as it will involve some lines of code where this Unicode is just a replacement of text/String –  Feb 08 '18 at 05:30
  • You could use the arrow symbols ←↑→↓ if the doubled arrow isn't a hard requirement. – William John Holden Feb 08 '18 at 05:33
  • @WilliamJohnHolden '>>' is a hard requirement –  Feb 08 '18 at 05:40
  • @camickr where can I find the jar for `TextIcon` and `RotatedIcon` –  Feb 08 '18 at 05:41
  • So a crazy idea that might not work could be to format your button text in HTML with an inline CSS style specifying a rotation matrix. Something like this: JButton button = new JButton(">>"); – William John Holden Feb 08 '18 at 05:50
  • Possible analogs: Name (codepoint). Upward White Double (8686), Black Up-pointing Double Triangle (9195), Double Logical and (10835). – Andrew Thompson Feb 08 '18 at 05:50
  • @WilliamJohnHolden Nope. Swing's HTML toolkit is **very** basic and does not support much CSS. – Andrew Thompson Feb 08 '18 at 05:51
  • @AndrewThompson how do I use this code ? any sample example ?? –  Feb 08 '18 at 06:03
  • @yshavit could you pls give me the link where you found this symbol `︽`? I need it in downwards, and similar single arrows in up and downwards as well. Thanks.. –  Feb 08 '18 at 06:04
  • *"how do I use this code?"* See [Character display/search for Unicode characters](https://stackoverflow.com/questions/18858312/character-display-search-for-unicode-characters). – Andrew Thompson Feb 08 '18 at 07:03
  • 1
    I pasted the link above. In the search field it presents you, search for the last term I mentioned, "double". Then scroll until you find it, or just search within the page for ︽. The down version is there, too. And notice how it's labeled something like "VERTICAL LEFT DOUBLE ANGLE BRACKET"? That suggests that the single version might be there if you search for just "ANGLE BRACKET" in that field. (Btw, these are all just basic searching skills, but those skills are very important to programming in this day and age!) – yshavit Feb 08 '18 at 07:48
  • @JohnDoe, in the links provided. – camickr Feb 08 '18 at 15:11

2 Answers2

2

You can also try search for unicodes that looks like rotated >> using the tool https://shapecatcher.com/index.html

Buginese letter ra: ᨑ

Seem like the best fit

Jens
  • 2,327
  • 25
  • 34
1

This would be more complicated if you have other characters on your button, but here's a simple example of how you could override the JButton's paintComponent method and rotate the graphics.

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);
    }
}
Amber
  • 2,413
  • 1
  • 15
  • 20