001/* 002 * SVG Salamander 003 * Copyright (c) 2004, Mark McKay 004 * All rights reserved. 005 * 006 * Redistribution and use in source and binary forms, with or 007 * without modification, are permitted provided that the following 008 * conditions are met: 009 * 010 * - Redistributions of source code must retain the above 011 * copyright notice, this list of conditions and the following 012 * disclaimer. 013 * - Redistributions in binary form must reproduce the above 014 * copyright notice, this list of conditions and the following 015 * disclaimer in the documentation and/or other materials 016 * provided with the distribution. 017 * 018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 019 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 020 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 021 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 022 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 023 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 024 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 025 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 026 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 027 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 028 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 029 * OF THE POSSIBILITY OF SUCH DAMAGE. 030 * 031 * Mark McKay can be contacted at mark@kitfox.com. Salamander and other 032 * projects can be found at http://www.kitfox.com 033 * 034 * Created on May 7, 2005, 4:15 AM 035 */ 036 037package com.kitfox.svg.app.beans; 038 039import java.awt.*; 040import javax.swing.*; 041 042/** 043 * Panel based on the null layout. Allows editing with absolute layout. When 044 * instanced, records layout dimensions of all subcomponents. Then, if the 045 * panel is ever resized, scales all children to fit new size. 046 * 047 * @author kitfox 048 */ 049public class ProportionalLayoutPanel extends javax.swing.JPanel 050{ 051 public static final long serialVersionUID = 1; 052 053 //Margins to leave on sides of panel, expressed in fractions [0 1] 054 float topMargin; 055 float bottomMargin; 056 float leftMargin; 057 float rightMargin; 058 059 /** Creates new form ProportionalLayoutPanel */ 060 public ProportionalLayoutPanel() 061 { 062 initComponents(); 063 } 064 065 @Override 066 public void addNotify() 067 { 068 super.addNotify(); 069 070 Rectangle rect = this.getBounds(); 071 JOptionPane.showMessageDialog(this, "" + rect); 072 } 073 074 075 /** This method is called from within the constructor to 076 * initialize the form. 077 * WARNING: Do NOT modify this code. The content of this method is 078 * always regenerated by the Form Editor. 079 */ 080 // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents 081 private void initComponents() 082 { 083 jPanel1 = new javax.swing.JPanel(); 084 085 setLayout(null); 086 087 addComponentListener(new java.awt.event.ComponentAdapter() 088 { 089 @Override 090 public void componentResized(java.awt.event.ComponentEvent evt) 091 { 092 formComponentResized(evt); 093 } 094 @Override 095 public void componentShown(java.awt.event.ComponentEvent evt) 096 { 097 formComponentShown(evt); 098 } 099 }); 100 101 add(jPanel1); 102 jPanel1.setBounds(80, 90, 280, 160); 103 104 } 105 // </editor-fold>//GEN-END:initComponents 106 107 private void formComponentShown(java.awt.event.ComponentEvent evt)//GEN-FIRST:event_formComponentShown 108 {//GEN-HEADEREND:event_formComponentShown 109 JOptionPane.showMessageDialog(this, "" + getWidth() + ", " + getHeight()); 110 111 }//GEN-LAST:event_formComponentShown 112 113 private void formComponentResized(java.awt.event.ComponentEvent evt)//GEN-FIRST:event_formComponentResized 114 {//GEN-HEADEREND:event_formComponentResized 115// TODO add your handling code here: 116 }//GEN-LAST:event_formComponentResized 117 118 119 // Variables declaration - do not modify//GEN-BEGIN:variables 120 private javax.swing.JPanel jPanel1; 121 // End of variables declaration//GEN-END:variables 122 123}