KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > workflow > designer > swing > status > DisplayItem


1 package com.opensymphony.workflow.designer.swing.status;
2
3 import java.awt.*;
4 import java.awt.font.FontRenderContext JavaDoc;
5 import javax.swing.*;
6
7 /**
8  * @author Hani Suleiman (hani@formicary.net)
9  * Date: Dec 24, 2003
10  * Time: 3:42:19 PM
11  */

12 public abstract class DisplayItem extends JPanel
13 {
14   private int preferredWidth;
15
16   public abstract String JavaDoc getItemName();
17
18   public DisplayItem()
19   {
20     setRequestFocusEnabled(false);
21     setFocusable(false);
22   }
23
24   public void setPreferredWidth(int i)
25   {
26     preferredWidth = i;
27   }
28
29   public int getPreferredWidth()
30   {
31     return preferredWidth;
32   }
33
34   private int getBarHeight()
35   {
36     return (int)getFont().getLineMetrics("dfghjklpqtABC", new FontRenderContext JavaDoc(null, true, false)).getHeight();
37   }
38
39   public Dimension getPreferredSize()
40   {
41     Dimension dim = new Dimension((getPreferredWidth() + getInsets().left + getInsets().right), (getBarHeight() + getInsets().top + getInsets().bottom + 4));
42     return dim;
43   }
44
45  }
46
Popular Tags