1 package discRack.presentation.dpanels; 2 3 import discRack.presentation.delements.*; 4 5 import java.awt.*; 6 7 13 public abstract class DControlPanel extends DPanel { 14 protected DPanel controlledPanel; 15 16 17 public DControlPanel (DCollection myOwner,String title, 18 boolean isVertical,boolean hasBorder) { 19 super(myOwner,0,title,isVertical,hasBorder); 20 } 21 22 public void setControlledPanel(DPanel controlledPanel) { 23 this.controlledPanel = controlledPanel; 24 } 25 26 protected Dimension getPreferredDimension (String [] s) { 27 double longest=0; 28 double w=0; 29 for (int i=0;i<s.length; i++) { 30 String n=s[i]; 31 try { 32 w=getFontMetrics(getFont()).stringWidth(s[i]); 33 if (w>longest) longest=w; 34 } catch(Exception ex) {} 35 } 36 double h=getFontMetrics(getFont()).getHeight(); 37 38 w=longest+25; 39 if (w<30) w=30; 41 42 return new Dimension((int)w,(int)h); 43 } 44 45 } 46 | Popular Tags |