Java Reference
In-Depth Information
L ISTING 8.9 Continued
animLabel = new JLabel(new
ImageIcon(loader.getResource(“images/working.gif”)));
resourceLabel.setBorder(BorderFactory.createEmptyBorder(6,6,6,6));
ImageLabel.setLayout(new BorderLayout());
ImageLabel.setBorder(BorderFactory.createRaisedBevelBorder());
ImageLabel.add(resourceLabel, BorderLayout.NORTH);
ImageLabel.add(MessageLabel, BorderLayout.SOUTH);
ImageLabel.add(animLabel, BorderLayout.CENTER);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(ImageLabel, BorderLayout.CENTER);
pack();
//Centers the window
Dimension size = getSize();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
if (size.height > screenSize.height) {
size.height = screenSize.height;
}
if (size.width > screenSize.width) {
size.width = screenSize.width;
60: }
setLocation((screenSize.width - size.width) / 2, (screenSize.height -
size.height) / 2);
}
8
/**
* Implements the Singleton Design Pattern
*
*/
public static Splash getInstance(){
if (splash == null)
splash = new Splash();
return splash;
}
/**
* Sets a message visible at the bottom
* @param text Text to show
*/
public static void setMessage(String text) {
if (splash != null)
80: splash.MessageLabel.setText(“ “ + text);
}
Search WWH ::




Custom Search