package example9_3_VirtualProxy; import javax.swing.Icon; import javax.swing.JFrame; import java.io.IOException; import java.net.URL; /** * A basic image viewing application * @author hornick */ public class ImageViewer extends JFrame { /** * Where to find resources */ public static final String baseDir = "src/example9_3_Proxy.virtualProxy/"; // a UI component that contains the image private ImageComponent imageComponent; public static void main(String[] args){ ImageViewer iv = new ImageViewer(); iv.initUI(); } // init the UI for this app private void initUI() { setTitle("Image Viewer"); Icon icon = null; // try { // TODO: where to do this? // } catch (Exception e) { // // TODO Auto-generated catch block // e.printStackTrace(); // System.exit(0); // } try { URL url = new URL("http://assets.overclock.net.s3.amazonaws.com/f/f7/f740be93_vbattach181511.jpeg"); icon = new ImageProxy(url); } catch (IOException e) { e.printStackTrace(); //TODO: change body of catch statement use File | Settings | File Templates. } setSize(icon.getIconWidth() + 800,icon.getIconHeight() + 100); // set the window size imageComponent = new ImageComponent(icon); // add the icon to the canvas getContentPane().add(imageComponent); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } }