1 54 package com.mullassery.act.task; 55 56 import java.awt.Dimension ; 57 import java.awt.event.WindowAdapter ; 58 import java.awt.event.WindowEvent ; 59 import java.io.File ; 60 61 import javax.swing.ImageIcon ; 62 import javax.swing.JFrame ; 63 import javax.swing.JLabel ; 64 65 import org.apache.tools.ant.Task; 66 67 import com.mullassery.act.util.GUIUtil; 68 69 74 public class ImageViewerTask extends Task { 75 76 File file; 77 78 public void execute() { 79 final JFrame jf = new JFrame ("ImageViewer : " + file); 80 jf.addWindowListener(new WindowAdapter () { 81 public void windowClosing(WindowEvent arg0) { 82 jf.dispose(); 83 } 84 }); 85 ImageIcon ic = new ImageIcon (file.getAbsolutePath()); 86 jf.getContentPane().add(new JLabel (ic)); 87 Dimension d = jf.getSize(); 88 d = new Dimension (); 89 jf.setSize( 90 ic.getImage().getWidth(jf) + d.width, 91 ic.getImage().getHeight(jf) + d.height); 92 GUIUtil.centralize(jf); 93 jf.show(); 94 } 95 96 public void setImage(File file) { 97 this.file = file; 98 } 99 100 } 101 | Popular Tags |