001 /*
002 * ProportionalLayoutPanel.java
003 *
004 * Created on May 7, 2005, 4:15 AM
005 */
006
007 package com.kitfox.svg.app.beans;
008
009 import java.awt.*;
010 import java.util.*;
011 import javax.swing.*;
012
013 /**
014 * Panel based on the null layout. Allows editing with absolute layout. When
015 * instanced, records layout dimensions of all subcomponents. Then, if the
016 * panel is ever resized, scales all children to fit new size.
017 *
018 * @author kitfox
019 */
020 public class ProportionalLayoutPanel extends javax.swing.JPanel
021 {
022 public static final long serialVersionUID = 1;
023
024 //Margins to leave on sides of panel, expressed in fractions [0 1]
025 float topMargin;
026 float bottomMargin;
027 float leftMargin;
028 float rightMargin;
029
030 /** Creates new form ProportionalLayoutPanel */
031 public ProportionalLayoutPanel()
032 {
033 initComponents();
034 }
035
036 public void addNotify()
037 {
038 super.addNotify();
039
040 Rectangle rect = this.getBounds();
041 JOptionPane.showMessageDialog(this, "" + rect);
042 }
043
044
045 /** This method is called from within the constructor to
046 * initialize the form.
047 * WARNING: Do NOT modify this code. The content of this method is
048 * always regenerated by the Form Editor.
049 */
050 // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
051 private void initComponents()
052 {
053 jPanel1 = new javax.swing.JPanel();
054
055 setLayout(null);
056
057 addComponentListener(new java.awt.event.ComponentAdapter()
058 {
059 public void componentResized(java.awt.event.ComponentEvent evt)
060 {
061 formComponentResized(evt);
062 }
063 public void componentShown(java.awt.event.ComponentEvent evt)
064 {
065 formComponentShown(evt);
066 }
067 });
068
069 add(jPanel1);
070 jPanel1.setBounds(80, 90, 280, 160);
071
072 }
073 // </editor-fold>//GEN-END:initComponents
074
075 private void formComponentShown(java.awt.event.ComponentEvent evt)//GEN-FIRST:event_formComponentShown
076 {//GEN-HEADEREND:event_formComponentShown
077 JOptionPane.showMessageDialog(this, "" + getWidth() + ", " + getHeight());
078
079 }//GEN-LAST:event_formComponentShown
080
081 private void formComponentResized(java.awt.event.ComponentEvent evt)//GEN-FIRST:event_formComponentResized
082 {//GEN-HEADEREND:event_formComponentResized
083 // TODO add your handling code here:
084 }//GEN-LAST:event_formComponentResized
085
086
087 // Variables declaration - do not modify//GEN-BEGIN:variables
088 private javax.swing.JPanel jPanel1;
089 // End of variables declaration//GEN-END:variables
090
091 }