コード例 #1
0
ファイル: klee-Slideshow.java プロジェクト: keverino/cs245
 public void actionPerformed(ActionEvent ae) {
   if (ae.getActionCommand() == "timer") {
     if (counter >= imagePaths.length) {
       timer.stop();
       counter = 0;
       PlayStopButton.setText("Play");
     } else {
       try {
         // if the array contains URLs
         if (imagePaths[counter].contains("http://")) {
           scrollPane.setToolTipText(imagePaths[counter]);
           imageIcon = new ImageIcon((new URL(imagePaths[counter++])));
           scrollPane.setViewportView(new JLabel(imageIcon));
         }
         // if the array contains local images
         else {
           image.setIcon(new ImageIcon(imagePaths[counter]));
           image.setToolTipText(imagePaths[counter++]);
         }
       } catch (MalformedURLException ex) {
         Logger.getLogger(Slideshow.class.getName()).log(Level.SEVERE, null, ex);
         image = new JLabel("?" + imagePaths);
       }
     }
   }
 }