01: package org.slf4j.migrator.helper;
02:
03: import java.awt.Component;
04:
05: import javax.swing.SpringLayout;
06:
07: public class SpringLayoutHelper {
08:
09: final SpringLayout sl;
10: final int basicPadding;
11:
12: public SpringLayoutHelper(SpringLayout springLayout,
13: int basicPadding) {
14: sl = springLayout;
15: this .basicPadding = basicPadding;
16: }
17:
18: public void placeToTheRight(Component relativeTo,
19: Component componentToPlace, int horizontalPadding,
20: int verticalPadding) {
21: sl.putConstraint(SpringLayout.WEST, componentToPlace,
22: horizontalPadding, SpringLayout.EAST, relativeTo);
23:
24: sl.putConstraint(SpringLayout.NORTH, componentToPlace,
25: verticalPadding, SpringLayout.NORTH, relativeTo);
26: }
27:
28: public void placeToTheRight(Component relativeTo,
29: Component componentToPlace) {
30: placeToTheRight(relativeTo, componentToPlace, basicPadding, 0);
31: }
32:
33: public void placeBelow(Component relativeTo,
34: Component componentToPlace) {
35: placeBelow(relativeTo, componentToPlace, 0, basicPadding);
36: }
37:
38: public void placeBelow(Component relativeTo,
39: Component componentToPlace, int horizontalPadding,
40: int verticalPadding) {
41: sl.putConstraint(SpringLayout.WEST, componentToPlace,
42: horizontalPadding, SpringLayout.WEST, relativeTo);
43:
44: sl.putConstraint(SpringLayout.NORTH, componentToPlace,
45: verticalPadding, SpringLayout.SOUTH, relativeTo);
46: }
47:
48: }
|