Browse Source

fixes Simulation playButton appearance when paused while running

Andreas T. Meyer-Berg 7 years ago
parent
commit
155387c84a
1 changed files with 4 additions and 8 deletions
  1. 4 8
      src/ui/view/TimePanel.java

+ 4 - 8
src/ui/view/TimePanel.java

@@ -89,8 +89,7 @@ public class TimePanel extends JPanel {
 				timer.setDelay(model.getTimerSpeed());
 				if (timeSlider.getValue() == model.getIterations() - 1) {
 					running = false;
-					playBtn.setIcon(new ImageIcon(new ImageIcon(this.getClass().getResource("/Button_Images/play.png"))
-							.getImage().getScaledInstance(30, 30, Image.SCALE_SMOOTH)));
+					playBtn.setIcon(new ImageIcon(Util.loadImage(this, "/Button_Images/play.png", 30, 30, Image.SCALE_SMOOTH)));
 					timer.stop();
 				}
 			}
@@ -143,17 +142,14 @@ public class TimePanel extends JPanel {
 			@Override
 			public void actionPerformed(ActionEvent e) {
 				running = !running;
-				playBtn.setIcon(new ImageIcon(Util.loadImage(this,"/Button_Images/pause.png",30,30)));//relocated this here. as it was duplicate before.
+				controller.setIsSimRunning(running);
 				if (running) {
-					if (!model.getIsSimRunning()) {
-						controller.setIsSimRunning(true);
-					}
 					timer.start();
 					timer.setDelay(model.getTimerSpeed());
-					//playBtn.setIcon(new ImageIcon(Util.loadImage(this,"/Button_Images/pause.png",30,30)));
+					playBtn.setIcon(new ImageIcon(Util.loadImage(this, "/Button_Images/pause.png", 30, 30, Image.SCALE_SMOOTH)));
 				} else {
 					timer.stop();
-					//playBtn.setIcon(new ImageIcon(Util.loadImage(this,"/Button_Images/pause.png",30,30)));
+					playBtn.setIcon(new ImageIcon(Util.loadImage(this, "/Button_Images/play.png", 30, 30, Image.SCALE_SMOOTH)));
 				}
 			}
 		});