I have an image within a Jlabel which I want to rotate 90 degrees right when the user hits the button. I've attempted it myself, but with various errors. I was told the best way to do it was to use Graphics2D?
Main Class:
private void SearchButtonActionPerformed(java.awt.event.ActionEvent evt) {
BufferedImage image;
try {
image = ImageIO.read(file);
Image scaled = image.getScaledInstance(Jlabel1.getWidth(), Jlabel1.getHeight(), 5);
Jlabel1.setIcon(new ImageIcon(scaled));
Button:
private void rotateButtonActionPerformed(java.awt.event.ActionEvent evt) {
Graphics2D userImage = (Graphics2D)JLabel1.getGraphics();
userImage.rotate(Math.toRadians(90));
userImage.drawImage(JLabel1, JLabel1.getHeight(), JLabel1.getWidth());
}