package jtaDiscRack.presentation.dpanels;
import jtaDiscRack.presentation.delements.*;
import java.awt.*;
/**
* Base class for panels with buttons that manages it's controlled panel.
*
* @author Sasa Bojanic
* @version 1.0
*/
public abstract class DControlPanel extends DPanel {
protected DPanel controlledPanel;
public DControlPanel (DCollection myOwner,String title,
boolean isVertical,boolean hasBorder) {
super(myOwner,0,title,isVertical,hasBorder);
}
public void setControlledPanel(DPanel controlledPanel) {
this.controlledPanel = controlledPanel;
}
protected Dimension getPreferredDimension (String[] s) {
double longest=0;
double w=0;
for (int i=0;i<s.length; i++) {
String n=s[i];
try {
w=getFontMetrics(getFont()).stringWidth(s[i]);
if (w>longest) longest=w;
} catch(Exception ex) {}
}
double h=getFontMetrics(getFont()).getHeight();
w=longest+25;
if (w<30) w=30;
return new Dimension((int)w,(int)h);
}
}
|