01: package com.opensymphony.workflow.designer.swing.status;
02:
03: import java.awt.*;
04: import java.awt.font.FontRenderContext;
05: import javax.swing.*;
06:
07: /**
08: * @author Hani Suleiman (hani@formicary.net)
09: * Date: Dec 24, 2003
10: * Time: 3:42:19 PM
11: */
12: public abstract class DisplayItem extends JPanel {
13: private int preferredWidth;
14:
15: public abstract String getItemName();
16:
17: public DisplayItem() {
18: setRequestFocusEnabled(false);
19: setFocusable(false);
20: }
21:
22: public void setPreferredWidth(int i) {
23: preferredWidth = i;
24: }
25:
26: public int getPreferredWidth() {
27: return preferredWidth;
28: }
29:
30: private int getBarHeight() {
31: return (int) getFont().getLineMetrics("dfghjklpqtABC",
32: new FontRenderContext(null, true, false)).getHeight();
33: }
34:
35: public Dimension getPreferredSize() {
36: Dimension dim = new Dimension(
37: (getPreferredWidth() + getInsets().left + getInsets().right),
38: (getBarHeight() + getInsets().top + getInsets().bottom + 4));
39: return dim;
40: }
41:
42: }
|