Advertisement
Guest User

Homework

a guest
Apr 27th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. package zad2;
  2.  
  3. import javax.swing.JFrame;
  4. import javax.swing.plaf.synth.SynthSeparatorUI;
  5.  
  6. import java.awt.image.BufferedImage;
  7. import java.io.File;
  8. import java.io.FilenameFilter;
  9. import java.io.IOException;
  10. import javax.imageio.ImageIO;
  11.  
  12. public class Imagestart extends JFrame{
  13. static int size;
  14. static int counter=0;
  15. //static int
  16. static int hight;
  17. static int width;
  18. public Imagestart(String adress,int time){
  19. final File dir = new File(adress);
  20. final String[] Extensions = new String[]{
  21. "gif", "png","bmp","jpg","JPG"
  22. };
  23. final FilenameFilter IMAGE_FILTER = new FilenameFilter(){
  24.  
  25. @Override
  26. public boolean accept(final File dir, String name) {
  27. for(final String ext : Extensions){
  28. if(name.endsWith("."+ext)){
  29. return true;
  30. }
  31. }
  32. System.out.println("Nope");
  33. return false;
  34. }
  35.  
  36. };
  37.  
  38.  
  39. if(dir.isDirectory()){
  40. for( File f : dir.listFiles(IMAGE_FILTER)){
  41. BufferedImage img = null;
  42. try{
  43. img = ImageIO.read(f);
  44. counter++;
  45. size = time;
  46. StartImage p = new StartImage(f.getAbsolutePath());
  47. add(p);
  48. pack();
  49. setDefaultCloseOperation(EXIT_ON_CLOSE);
  50. setLocationRelativeTo(null);
  51. setVisible(true);
  52. }catch(IOException e){
  53. System.out.println(e);
  54. }
  55. System.out.println(f.getAbsolutePath());
  56. try {
  57. Thread.currentThread().sleep(2000);
  58. } catch (InterruptedException e) {
  59. e.printStackTrace();
  60. }
  61. }
  62.  
  63. }
  64.  
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement