hi, I am wanting to rotate an image 90 degrees when you press a button. However so far i can only get it to rotate once, and then it stops. I've tried rotating the image on its own and using the label to rotate it
Here is my code
BufferedImage rotatedImg = new BufferedImage(editlabel.getWidth(), editlabel.getHeight(), BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = (Graphics2D)rotatedImg.getGraphics();
g2.rotate(Math.toRadians(90), editlabel.getWidth()/2, editlabel.getHeight()/2);
g2.drawImage(image, 0, 0, editlabel.getWidth(), editlabel.getHeight(), null);
editlabel.setIcon(new ImageIcon(rotatedImg));

Any help, in where i am going wrong will be greatly appreciated
Cheers

hi, I am wanting to rotate an image 90 degrees when you press a button. However so far i can only get it to rotate once, and then it stops. I've tried rotating the image on its own and using the label to rotate it
Here is my code
BufferedImage rotatedImg = new BufferedImage(editlabel.getWidth(), editlabel.getHeight(), BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = (Graphics2D)rotatedImg.getGraphics();
g2.rotate(Math.toRadians(90), editlabel.getWidth()/2, editlabel.getHeight()/2);
g2.drawImage(image, 0, 0, editlabel.getWidth(), editlabel.getHeight(), null);
editlabel.setIcon(new ImageIcon(rotatedImg));

Any help, in where i am going wrong will be greatly appreciated
Cheers

Managed to fix it, silly mistake. I was just making it go to 90degrees all the time, which on the first button press, it reaches so none of the other buttons clicks would do anything as its already on 90. Silly me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.