code: public void setImage(BufferedImage im) {
  		icon.setImage(im);
  		if (image == null) {
  			this.image = im;
  //			this.setSize(image.getWidth(), image.getHeight());
  			int panelX = image.getWidth(); 
  			int panelY = image.getHeight(); 
  			panel.setSize(panelX, panelY);
  
  //			Toolkit tk = Toolkit.getDefaultToolkit();  
  //			int xSize = ((int) tk.getScreenSize().getWidth());  
  //			int ySize = ((int) tk.getScreenSize().getHeight());
  			
  			try {
  				UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  			} catch (ClassNotFoundException e) {
  				// TODO Auto-generated catch block
  				e.printStackTrace();
  			} catch (InstantiationException e) {
  				// TODO Auto-generated catch block
  				e.printStackTrace();
  			} catch (IllegalAccessException e) {
  				// TODO Auto-generated catch block
  				e.printStackTrace();
  			} catch (UnsupportedLookAndFeelException e) {
  				// TODO Auto-generated catch block
  				e.printStackTrace();
  			}
  			GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
  			Rectangle bounds = ge.getMaximumWindowBounds();
  
  			int deltaX = 30;
  			int deltaY = 50;
  			int xSize = Math.min(bounds.width, panelX+deltaX);
  			int ySize = Math.min(bounds.height, panelY+deltaY);
  			
  			this.setPreferredSize(new Dimension(xSize, ySize));
  			
  			this.setResizable(true);
  			this.pack();
  		}
  		this.getContentPane().repaint();
  		if (!this.isVisible()) this.setVisible(true);
  	}
docs: Force the visualizer to display a given image.
  @param im The image to be displayed.