Java Reference
In-Depth Information
A singleton class is a class that can have only one instance, reachable from a global
point of access. There are several slightly different ways to achieve this behavior with
the Java language, but a private constructor is always needed.
Listing 11.1 illustrates the various aspects of the javax.jnlp API as it pertains to the client
L ISTING 11.1 The Utilities Class
package com.marinilli.b2.c11.util;
import javax.swing.ImageIcon;
import java.awt.image.BufferedImage;
import javax.jnlp.UnavailableServiceException;
import javax.jnlp.ServiceManager;
import javax.jnlp.BasicService;
import java.util.ResourceBundle;
* Chapter 11 - Utilities
* @author Mauro Marinilli
* @version 1.0
public class Utilities {
private static Utilities util;
private static ClassLoader loader;
private static BasicService basicService;
private static ImageIcon EMPTY_ICON =
new ImageIcon(new BufferedImage(24,24,BufferedImage.TYPE_INT_RGB));
private ResourceBundle msg;
private static String bundleFilename = “messages”;
private Utilities() {
loader = getClass().getClassLoader();
basicService =
try {
msg = ResourceBundle.getBundle(bundleFilename);
} catch (java.util.MissingResourceException mre) {
msg = null;
System.out.println(“Utilities (init)
Couldn't find any resource bundle.”);
Search WWH ::

Custom Search