View Javadoc

1   /***
2    * Created by IntelliJ IDEA.
3    * User: gareth
4    * Date: Sep 4, 2003
5    * Time: 6:13:08 PM
6    */
7   package com.tapina.robe.swi.wimp;
8   
9   import javax.swing.*;
10  import java.awt.*;
11  
12  public final class IconBar {
13      private static IconBar ourInstance;
14  
15      public synchronized static IconBar getInstance() {
16          if (ourInstance == null) {
17              ourInstance = new IconBar();
18          }
19          return ourInstance;
20      }
21  
22      private IconBar() {
23      }
24  
25      private JFrame window;
26  
27      private synchronized JFrame getWindow() {
28          if (window == null) {
29              window = new JFrame("ROBE Icon Bar");
30              window.getContentPane().setLayout(new FlowLayout(FlowLayout.RIGHT, 8, 0));
31          }
32          return window;
33      }
34  
35      public final void createIcon(Icon icon) {
36          JFrame window = getWindow();
37          window.getContentPane().add(icon.getComponent());
38          window.pack();
39          window.show(); // Bring to the top
40      }
41  }
42