Java Reference
In-Depth Information
N OTE
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
side.
L ISTING 11.1 The Utilities Class
package com.marinilli.b2.c11.util;
import javax.swing.ImageIcon;
import java.awt.image.BufferedImage;
import java.net.URL;
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 =
(BasicService)getService(“javax.jnlp.BasicService”);
initializeDefaultResources();
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