I'm trying to do two things here 1. I have an imageIcon in my code ( called dice ) that when you press on it, it changes to a moving imageIcon ( called dice2 ). however i failed resizing the moving imageIcon 2. setting a timer for dice2 and when its done "dice" shows up
here is my code so far
ImageIcon dice = new ImageIcon("dice.png") ;
Image image = dice.getImage(); // transform it
Image newimg = image.getScaledInstance(150, 120,java.awt.Image.SCALE_SMOOTH); // scale it the smooth way
dice = new ImageIcon(newimg) ;
dice_1 = new JButton(dice);
dice_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dicePanel.remove(dice_1);
dicePanel.revalidate();
dicePanel.repaint();
ImageIcon dice2 = new ImageIcon("dice.gif");
dice_1 = new JButton(dice2);
dice_1.setOpaque(false);
dice_1.setContentAreaFilled(false);
dice_1.setBorderPainted(false);
dicePanel.add(dice_1);
// random number
Random r = new Random();
R = r.nextInt(10) + 2;
randomNumbe.setText("تقدم " + R + " خطوة");
}
});