KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > eclipse > console > editors > ColorManager


1 package org.hibernate.eclipse.console.editors;
2
3 import java.util.HashMap JavaDoc;
4 import java.util.Iterator JavaDoc;
5 import java.util.Map JavaDoc;
6
7 import org.eclipse.swt.graphics.Color;
8 import org.eclipse.swt.graphics.RGB;
9 import org.eclipse.swt.widgets.Display;
10
11 public class ColorManager {
12
13     protected Map JavaDoc fColorTable = new HashMap JavaDoc(10);
14
15     public void dispose() {
16         Iterator JavaDoc e = fColorTable.values().iterator();
17         while (e.hasNext())
18              ((Color) e.next()).dispose();
19     }
20     public Color getColor(RGB rgb) {
21         Color color = (Color) fColorTable.get(rgb);
22         if (color == null) {
23             color = new Color(Display.getCurrent(), rgb);
24             fColorTable.put(rgb, color);
25         }
26         return color;
27     }
28 }
29
Popular Tags