KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > xml > panels > XMLControlPanel


1 /* XMLControlPanel.java
2  *
3  * Authors:
4  * Stefanovic Nenad chupo@iis.ns.ac.yu
5  * Bojanic Sasa sasaboy@neobee.net
6  * Puskas Vladimir vpuskas@eunet.yu
7  * Pilipovic Goran zboniek@uns.ac.yu
8  *
9  */

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 JavaDoc 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 JavaDoc[] s) {
32       double longest=0;
33       double w=0;
34       for (int i=0;i<s.length; i++) {
35          String JavaDoc n=s[i];
36          try {
37             w=getFontMetrics(getFont()).stringWidth(s[i]);
38             if (w>longest) longest=w;
39          } catch(Exception JavaDoc ex) {}
40       }
41       double h=getFontMetrics(getFont()).getHeight();
42
43       w=longest+25;
44       //w=longest+20;
45
if (w<30) w=30;
46
47       return new Dimension((int)w,(int)h);
48    }
49
50 }
51
Popular Tags