SwingImage extends SwingElement implements XulImage { public void setSrc( String src ) { URL url = SwingImage.class.getClassLoader().getResource( this.container.getXulLoader().getRootDir() + src ); if ( url == null ) { try { File f = new File( src ); if ( f.exists() ) { url = f.toURL(); } } catch ( MalformedURLException e ) { } } if ( url == null ) { logger.error( "Could not find resource: " + src ); return; } ico = new ImageIcon( url ); if ( ico == null ) { logger.error( "Image could not be found: " + ico ); } this.src = src; layout(); } SwingImage( Element self, XulComponent parent, XulDomContainer domContainer, String tagName ); String getSrc(); void setSrc( String src ); void setSrc( Object img ); void setVisible( boolean visible ); @Override void layout(); void refresh();  }
@Test public void testSetSrc() throws Exception { SwingImage img = (SwingImage) doc.getElementById( "img_dimed" ); assertEquals( "testImage.png", img.getSrc() ); Image newImg = new ImageIcon( ImageHandler.class.getClassLoader().getResource( "documents/testImage2.png" ) ) .getImage(); img.setSrc( newImg ); }