01: package discRack.presentation.dpanels;
02:
03: import discRack.presentation.delements.*;
04:
05: import java.awt.*;
06:
07: /**
08: * Base class for panels with buttons that manages it's controlled panel.
09: *
10: * @author Sasa Bojanic
11: * @version 1.0
12: */
13: public abstract class DControlPanel extends DPanel {
14: protected DPanel controlledPanel;
15:
16: public DControlPanel(DCollection myOwner, String title,
17: boolean isVertical, boolean hasBorder) {
18: super (myOwner, 0, title, isVertical, hasBorder);
19: }
20:
21: public void setControlledPanel(DPanel controlledPanel) {
22: this .controlledPanel = controlledPanel;
23: }
24:
25: protected Dimension getPreferredDimension(String[] s) {
26: double longest = 0;
27: double w = 0;
28: for (int i = 0; i < s.length; i++) {
29: String n = s[i];
30: try {
31: w = getFontMetrics(getFont()).stringWidth(s[i]);
32: if (w > longest)
33: longest = w;
34: } catch (Exception ex) {
35: }
36: }
37: double h = getFontMetrics(getFont()).getHeight();
38:
39: w = longest + 25;
40: //w=longest+20;
41: if (w < 30)
42: w = 30;
43:
44: return new Dimension((int) w, (int) h);
45: }
46:
47: }
|