2) Context-menu: right-click on
the component in either the
editor or in the Outline view, and choose from the menu options:
In either
case, you will be asked to name the
component (a default name will be provided for you). Also, if the
component has text or image properties, if it is being added to a
container which uses layout constraints, or is a container itself, you
will be able to specify all these things using the dialog which will
appear:| public Image loadImage(String imgUrl) { try { super.loadImage(imgUrl); URL url = getClass().getClassLoader().getResource(imgUrl); if(url != null) return new ImageIcon(url).getImage(); } catch (Exception e) { e.printStackTrace(); } return null; } |
** You need to override the loadImage method because Eclipse 3+ sets a ContentHandlerFactory for URLConnections which doesn't seem capable of handling gif images, and so the url.getContent() method in the SimpleBeanInfo loadImage method does *not* return an ImageProducer, and hence the method does not return an image. The above method, however, does work in Eclipse 3.0+ because it does not depend on the url.getContent(). |
