0
爲了繪製和旋轉一些圖像,我重寫了一個Jpanel的paintcomponent,但它具有旋轉其他東西的不必要的副作用,例如JLabel添加到JPanel等。我已經嘗試在繪製後旋轉回來圖像但JLabels似乎抖動。Java Swing PaintComponent旋轉jlabels
請注意,我在圖像中的不同點(不是圖像的中心)周圍旋轉每個圖像,因此在圖像緩衝區內旋轉圖像不適合?
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
g2.rotate(Math.toRadians(+(angle)), 137, 188);
g2.drawImage(image1, 125, 131, this);
g2.rotate(Math.toRadians(-(angle)), 137, 188);
g2.rotate(Math.toRadians(+(angle2)), 137, 188);
g2.drawImage(image2, 125, 131, this);
g2.rotate(Math.toRadians(-(angle2)), 137, 188);
}
相關示例見[這裏](http://stackoverflow.com/a/3420651/230513)。 – trashgod 2014-12-03 21:58:42