Ejemplo n.º 1
0
 public void init() {
   frame = new Frame("PictureViewer");
   Panel pb = new Panel();
   Button select = new Button("choose pic");
   previous = new Button("previous");
   next = new Button("next");
   select.addActionListener(this);
   previous.addActionListener(this);
   next.addActionListener(this);
   pb.add(select);
   pb.add(previous);
   pb.add(next);
   mc = new MyCanvas();
   mc.setBackground(new Color(200, 210, 230));
   mc.addComponentListener(mc);
   frame.add(pb, "North");
   frame.add(mc, "Center");
   frame.setSize(360, 360);
   frame.setLocation(400, 200);
   frame.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           System.exit(0);
         }
       });
   frame.setVisible(true);
   this.validateButton();
   filter = new MyFilter();
   fd_load = new FileDialog(frame, "Open file", FileDialog.LOAD);
   fd_load.setFilenameFilter(filter);
 }
Ejemplo n.º 2
0
 public void display(File f) {
   try {
     BufferedImage bi = ImageIO.read(f);
     mc.setImage(bi);
     frame.setTitle("PictureViewer - [" + f.getName() + "]");
   } catch (Exception e) {
     e.printStackTrace();
   }
   mc.repaint();
 }