001 /* 002 * Copyright (c) 2005, romain guy (romain.guy@jext.org) and craig wickesser (craig@codecraig.com) 003 * All rights reserved. 004 * 005 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 006 * 007 * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 008 * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 009 * * Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 010 * 011 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 012 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 013 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 014 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 015 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 016 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 017 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 018 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 019 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 020 * POSSIBILITY OF SUCH DAMAGE. 021 */ 022 023 package net.java.swingfx.jdraggable.demo; 024 025 import java.awt.Color; 026 import java.awt.Component; 027 028 import javax.swing.JPanel; 029 import javax.swing.border.LineBorder; 030 import javax.swing.border.TitledBorder; 031 032 import net.java.swingfx.jdraggable.Draggable; 033 034 035 /** 036 * A {@link javax.swing.JPanel} which implements the {@link net.java.swingfx.jdraggable.Draggable} 037 * interface. 038 * 039 * @author craig 040 * @since v0.1 041 * <br> 042 * $Header: /cvs/swingfx/docs/api/src-html/net/java/swingfx/jdraggable/demo/DraggablePanel.html,v 1.1 2005/06/23 00:24:52 codecraig Exp $ 043 */ 044 public class DraggablePanel extends JPanel implements Draggable { 045 private static final long serialVersionUID = 3256725069878538292L; 046 047 private TitledBorder border; 048 049 public DraggablePanel() { 050 border = new TitledBorder(new LineBorder(Color.BLACK), "JPanel (,)"); 051 setBorder(border); 052 } 053 054 /* (non-Javadoc) 055 * @see java.awt.Component#setLocation(int, int) 056 */ 057 public void setLocation(int x, int y) { 058 super.setLocation(x, y); 059 border.setTitle("JPanel (" + getX() + "," + getY() + ")"); 060 repaint(); 061 } 062 063 /* (non-Javadoc) 064 * @see com.codecraig.jdraggable.Draggable#getComponent() 065 */ 066 public Component getComponent() { 067 return this; 068 } 069 }