2 Replies Latest reply: Aug 16, 2009 12:01 AM by 843849 RSS

    Diaporama en J2ME

    843849
      Hello,
      I have a small project to NetBeans for a PDA that runs with Java
      I do a new project>> Java ME>> CDC Application
      I tried an example that works in Java Standasr, but that I do copy paste code on my CDC, it gives me an error message:
      javax.imageio does not exist
      Enclosed my Java application
      permuter
           //javax.imageio does not exist

      import java.io.*;
      import java.io.IOException;
      import javax.imageio.ImageIO;
      import javax.swing.ImageIcon;
      import javax.swing.JFrame;
      import javax.swing.JLabel;
      import javax.swing.JScrollPane;

      public class Diaporama extends JFrame implements Runnable {

      private static final long serialVersionUID = 1L;

      private String folder;

      private String[] images;

      private int index;

      private JLabel image;

      public Diaporama(File folder) {
      super("Diaporama");
      images = folder.list();
      this.folder = folder.getAbsolutePath();
      index = 0;

      setSize(800, 600);
      image = new JLabel();
      add(new JScrollPane(image));

      setVisible(true);
      //setDefaultCloseOperation(EXIT_ON_CLOSE);

      }

      public void lireImage(String imageName) throws IOException {
      System.out.println(folder + imageName);
      image.setIcon(new ImageIcon(ImageIO.read(new File(folder + "\\"
      + imageName))));
      }

      public void run() {
      while (true) {

      try {
      lireImage(images[index]);
      } catch (IOException e) {
      e.printStackTrace();
      } catch (NullPointerException e) {
      }

      try {
      Thread.sleep(2000);
      } catch (InterruptedException e) {
      e.printStackTrace();
      }

      index = (index + 1) % images.length;

      }
      }

      public static void main(String[] args) {
      Diaporama diap = new Diaporama(new File("C:\\Images"));
      new Thread(diap).start();
      }
      }