/Users/lyon/j4p/src/gui/layouts/PreferredBoundable.java
|
1 /*
2 * Created by DocJava, Inc.
3 * User: lyon
4 * Date: Mar 20, 2003
5 * Time: 9:05:23 AM
6 */
7 package gui.layouts;
8
9 import java.awt.*;
10
11 public class PreferredBoundable
12 implements BoundableInterface {
13 public void setBounds(Component c,
14 int x, int y,
15 int w, int h) {
16 Dimension wantedSize = new Dimension(w, h);
17 Dimension d = c.getPreferredSize();
18 d = min(d, wantedSize);
19 c.setBounds(x, y, d.width, d.height);
20 }
21
22 public Dimension min(Dimension d1, Dimension d2) {
23 if (d1.width < d2.width) return d1;
24 if (d1.height < d2.height) return d1;
25 return d2;
26 }
27 }
28