1 10 11 12 package org.enhydra.jawe.xml.panels; 13 14 import org.enhydra.jawe.xml.*; 15 16 import java.awt.*; 17 18 public abstract class XMLControlPanel extends XMLPanel { 19 protected XMLPanel controlledPanel; 20 21 22 public XMLControlPanel (XMLCollection myOwner,String title, 23 boolean isVertical,boolean hasBorder) { 24 super(myOwner,0,title,XMLPanel.BOX_LAYOUT,isVertical,hasBorder); 25 } 26 27 public void setControlledPanel(XMLPanel controlledPanel) { 28 this.controlledPanel = controlledPanel; 29 } 30 31 protected Dimension getPreferredDimension (String [] s) { 32 double longest=0; 33 double w=0; 34 for (int i=0;i<s.length; i++) { 35 String n=s[i]; 36 try { 37 w=getFontMetrics(getFont()).stringWidth(s[i]); 38 if (w>longest) longest=w; 39 } catch(Exception ex) {} 40 } 41 double h=getFontMetrics(getFont()).getHeight(); 42 43 w=longest+25; 44 if (w<30) w=30; 46 47 return new Dimension((int)w,(int)h); 48 } 49 50 } 51 | Popular Tags |