/* * * Copyright (C) 1997 Jayakrishnan Nair jk@csr.uvic.ca * WWW: http://www.csc.uvic.ca/~jk * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ import java.awt.*; public class Border extends Panel { protected int thickness; protected int gap; protected DrawnRectangle border; protected static int defaultThickness = 0; protected static int defaultGap = 0; public Border(Component borderMe) { this(borderMe,defaultThickness,defaultGap); } public Border(Component borderMe, int thickness) { this(borderMe,thickness,defaultGap); } public Border(Component borderMe, int thickness, int gap) { this.thickness = thickness; this.gap = gap; setLayout(new BorderLayout()); add("Center",borderMe); } public Insets insets() { return new Insets(thickness+gap,thickness+gap,thickness+gap,thickness+gap); } public Rectangle getInnerBounds() { return border().getInnerBounds(); } public void setLineColor(Color c) { border().setLineColor(c); } public Color getLineColor() { return border().getLineColor(); } public void paint(Graphics g) { border().paint(); } public void resize(int w, int h) { Point location = location(); reshape(location.x,location.y,w,h); } public void reshape(int x, int y, int w, int h) { super.reshape(x,y,w,h); border().resize(w,h); } protected DrawnRectangle border() { if(border == null) border = new DrawnRectangle(this,thickness); return border; } }