swingutils.resources

This module contains helper functions to load resources (=files) contained in jars, or anywhere else in the class path.

swingutils.resources.getResource(path, classloader=None)

Loads a resource from anywhere on the classpath.

Parameters:
  • path – path to the resource (separate elements with ‘/’)
  • classloader – class loader to use for loading the resource
Return type:

java.lang.Object

swingutils.resources.getResourceAsStream(path, classloader=None)

Opens a stream to a resource anywhere on the classpath.

Parameters:
  • path – path to the resource (separate elements with ‘/’)
  • classloader – class loader to use for loading the resource
Return type:

java.io.InputStream

swingutils.resources.loadImage(path, classloader=None)

Loads an image resource as java.awt.Image from anywhere on the class path. Supported image types are JPEG, PNG and GIF, and possibly others if you have installed any extensions to the ImageIO system (such as Java Advanced Imaging).

Parameters:
  • path – path to the resource (separate elements with ‘/’)
  • classloader – class loader to use for loading the resource
Return type:

java.awt.Image

swingutils.resources.loadImageIcon(path, classloader=None)

Loads an image resource as an ImageIcon from anywhere on the class path.

Parameters:
  • path – Path to the resource (separate elements with ‘/’)
  • classloader – class loader to use for loading the resource
Return type:

javax.swing.ImageIcon