Duplicate :
|
FULL PRODUCT VERSION : java version " 1.7.0_21 " Java(TM) SE Runtime Environment (build 1.7.0_21-b12) Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode) ADDITIONAL OS VERSION INFORMATION : Mac OS X 10.7.5 A DESCRIPTION OF THE PROBLEM : Rotated String is drawn to the opposite direction on Mac OS X. When we rotate graphics by g.rotate(?Math.PI / 2) and g.drawString( " ABC " ), " B " should be drawn upper " A " . But " B " is drawn under " A " . " C " is drawn under the " B " . REGRESSION. Last worked in version 6u45 STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : 1. Run the program to test 2. Check the shown window EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - 90 degrees rotated " ABC123 " should be shown. ACTUAL - Rotated " 321CBA " is shown at the wrong position. REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import javax.swing.JFrame; import javax.swing.SwingUtilities; public class RotatedStringFrame extends JFrame { @Override public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setFont(new Font(Font.SERIF, Font.PLAIN, 24)); g2.rotate(-Math.PI / 2.0); g2.drawString( " ABC123 " , -200.0f, 40.0f); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { RotatedStringFrame frame = new RotatedStringFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(200, 400); frame.setVisible(true); } }); } } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : We can avoid this bug by using drawString(AttributedStringIterator) instead of drawString(String).