//Filename: CampeauSpringLayout.java //Author: Patrick Campeau import java.awt.Component; import javax.swing.SpringLayout; public class CampeauSpringLayout extends SpringLayout { public CampeauSpringLayout() { super(); } //====================================================================== //Place newItem at any location (x,y) with respect to the target's //top left corner. //====================================================================== public void placeAt(Component newItem, int x, int y, Component target) { //x putConstraint(SpringLayout.WEST, newItem, x, SpringLayout.WEST, target); //y putConstraint(SpringLayout.NORTH, newItem, y, SpringLayout.NORTH, target); } //====================================================================== //Place newItem to the right of target separating them by gap. //====================================================================== public void placeRightOf(Component newItem, int gap, Component target) { //x putConstraint(SpringLayout.WEST, newItem, gap, SpringLayout.EAST, target); //y putConstraint(SpringLayout.NORTH, newItem, 0, SpringLayout.NORTH, target); } //====================================================================== //Place newItem to the left of target separating them by gap. //====================================================================== public void placeLeftOf(Component newItem, int gap, Component target) { //x putConstraint(SpringLayout.EAST, newItem, gap * -1, SpringLayout.WEST, target); //y putConstraint(SpringLayout.NORTH, newItem, 0, SpringLayout.NORTH, target); } //====================================================================== //Place newItem below target separating them by gap. //====================================================================== public void placeUnder(Component newItem, int gap, Component target) { //x putConstraint(SpringLayout.WEST, newItem, 0, SpringLayout.WEST, target); //y putConstraint(SpringLayout.NORTH, newItem, gap, SpringLayout.SOUTH, target); } //====================================================================== //Place newItem above target separating them by gap. //====================================================================== public void placeAbove(Component newItem, int gap, Component target) { //x putConstraint(SpringLayout.WEST, newItem, 0, SpringLayout.WEST, target); //y putConstraint(SpringLayout.SOUTH, newItem, gap * -1, SpringLayout.NORTH, target); } //====================================================================== }