1 package com.opensymphony.workflow.designer.swing.status; 2 3 import java.awt.*; 4 import java.awt.font.FontRenderContext ; 5 import javax.swing.*; 6 7 12 public abstract class DisplayItem extends JPanel 13 { 14 private int preferredWidth; 15 16 public abstract String 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 (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 |