You are here:

Java/Skew and Bend JLabel in Swing

Advertisement


Question
Hello Sir,

I checked your link and it was very helpful for rotating JLabel in swing.
http://en.allexperts.com/q/Java-1046/2010/6/Move-JLabel-angle-1.htm

By this link I got Idea, But here one problem for me.
Is there any way to add skew and bend(separately) feature into this RotatedJLabel.java file. So we just call the method like rotate the jlabel (rjl.setRotation(30);) likewise,
I am very confused to how to implement that both functionality with same RotatedJLabel.java class.

Can you help me for this?
Give me some more idea...

Thanks,
Prashant.

Answer
First, I didn't answer that question, it was someone else that answers questions here.

You can shear/scale/rotate pretty easily, but bending is more difficult. For that you will need to use the Java Advanced Imaging library.

To use the RotatedJLabel class simply add it as a component in a swing enviroment, and use the setRotation to change it.

Note that the class is probably more than you need. If you just want to draw a rotated string you can use font.deriveFont(0, tx) where tx is your AffineTransform.

E.g.

g.setFont(g.getFont().deriveFont(0, AffineTransform.getRotateInstane(Math.PI/2));
g.drawString("String", 50, 50);

Java

All Answers


Answers by Expert:


Ask Experts

Volunteer


Artemus Harper

Expertise

I have a Masters in computer science. I can answer questions on core J2SE, swing and graphics. Please no questions about JSP or J2ME.

Experience

I have experience in Core Java, good background in Java swing/gui, some experience with JNI, Java reflection. Some experience in bio-informatics. Basics in c++ and c#

Organizations
Washington State University

Education/Credentials
MS in Computer Science from Washington State University and a BS in Mathematics and Computer Science from Central Washington University.

©2016 About.com. All rights reserved.