home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / Papers / OS Shell in Java / Facade / DesktopFrame.java < prev    next >
Encoding:
Java Source  |  1998-06-18  |  18.1 KB  |  556 lines  |  [TEXT/dosa]

  1. //    DesktopFrame.java : this is a Java source code file for the program Facade.
  2. //    Copyright 1998, Andrew S. Downs
  3. //    andrew.downs@tulane.edu
  4. //
  5. //    This source code is distributed as freeware.
  6. //    Just keep this author information in the file.  Enjoy!
  7.  
  8. import java.awt.*;
  9. import java.awt.event.*;
  10. import java.io.*;
  11. import java.util.*;
  12. import com.sun.java.swing.*;
  13.  
  14. public class DesktopFrame extends DesktopWindow implements Serializable, MouseListener, MouseMotionListener, FilenameFilter {
  15.     boolean drag = false;
  16.     boolean shade = false;
  17.     boolean zoom = false;
  18.     boolean resize = false;
  19.     
  20.     int resizeX = 0;
  21.     int resizeY = 0;
  22.     int initialX = 0;
  23.     int initialY = 0;
  24.     int prevX = 0;
  25.     int prevY = 0;
  26.     int prevWidth = 0;
  27.     int prevHeight = 0;
  28.     int prevHeightShade = 0;
  29.     
  30.     transient Polygon upArrowPolygon = new Polygon();
  31.     transient Polygon downArrowPolygon = new Polygon();
  32.     
  33.     transient Rectangle sizeBox = new Rectangle( 2, 2, 10, 10 );
  34.     transient Rectangle closeBox = new Rectangle( 2, 2, 10, 10 );
  35.     transient Rectangle titleBar = new Rectangle( 12, 2, 10, 10 );
  36.     transient Rectangle zoomBox = new Rectangle( 12, 2, 10, 10 );
  37.     transient Rectangle shadeBox = new Rectangle( 12, 2, 10, 10 );
  38.     transient Rectangle upArrowBox = new Rectangle( -1, -1, 10, 10 );
  39.     transient Rectangle downArrowBox = new Rectangle( -1, -1, 10, 10 );
  40.     transient Rectangle vScrollBar = new Rectangle( -1, -1, 16, 10 );
  41.     
  42.     String path;
  43.     transient String[] contents = new String[ 20 ];
  44.  
  45.     transient JScrollPane pane;
  46.     transient JPanel panel;
  47.  
  48.     DesktopFrame() {
  49.         super();
  50.         this.addMouseListener( this );
  51.         this.addMouseMotionListener( this );
  52.         Desktop.addWindow( this );
  53.         Desktop.setTopFrame( this );
  54.     }
  55.     
  56.     DesktopFrame( String s ) {
  57.         super();
  58.         this.setPath( s );
  59.         this.setLayout( null );
  60.         this.setBounds( 100, 100, 300, 200 );
  61.         this.addFileTree( s );
  62.         this.addMouseListener( this );
  63.         this.addMouseMotionListener( this );
  64.         Desktop.addWindow( this );
  65.         Desktop.setTopFrame( this );
  66.     }
  67.  
  68.     public boolean accept( File f, String s ) {
  69.         return true;
  70.     }
  71.  
  72.     public Insets getInsets() {
  73. //        return new Insets( 20, 5, 10, 5 );
  74.         return new Insets( 20, 5, 4, 4 );
  75.     }
  76.     
  77.     public void addFileTree( String s ) {
  78.         pane = new JScrollPane();
  79.         pane.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS );
  80.         pane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
  81. //        pane.getViewport().setLayout( new GridLayout( 3, 3 ) );
  82.  
  83.         String defaultVolume = s;
  84.         
  85.         if ( defaultVolume == null )
  86.             return;
  87.         
  88.         File theDir = new File( defaultVolume );
  89.  
  90.         if ( !theDir.isDirectory() )
  91.             return;
  92.             
  93.         contents = theDir.list();
  94.         int tempLength = 0;
  95.  
  96.         if ( contents == null ) {
  97.             System.out.println( "path contents == null" );
  98.             //return;
  99.         }
  100.         else
  101.             tempLength = contents.length;
  102.  
  103.         JPanel p = new JPanel();
  104.         p.setLayout( new GridLayout( 5, 3, 5, 5 ) );
  105. //        pane.getViewport().setLayout( new GridLayout( 4, ( tempLength / 3 ) + 1 ) );
  106.         
  107.         char pathSeparatorChar = theDir.pathSeparatorChar;
  108.         char separatorChar = theDir.separatorChar;
  109.         Vector v = new Vector();
  110.         v.addElement( Global.spaceSep );
  111. //        v.addElement( Global.sep00 );
  112.  
  113.         int loc = 0;
  114.         int k = 0;
  115.         
  116.         for ( int j = 0; j < tempLength; j++ ) {
  117.             File tempFile = new File( theDir, contents[ j ] );
  118.  
  119.             contents[ j ] = new String( contents[ j ].replace( pathSeparatorChar, ' ' ) );
  120.             contents[ j ] = new String( contents[ j ].replace( separatorChar, ' ' ) );
  121.  
  122.             for ( int l = 0; l < v.size(); l++ ) {
  123.                 // Parse root volume name.
  124.                 // Remove leading '%20' character.
  125.                 loc = contents[ j ].indexOf( ( String )v.elementAt( l ) );
  126.     
  127.                 if ( loc == 0 ) {
  128.                     contents[ j ] = new String( contents[ j ].substring( ( ( String )v.elementAt( l ) ).length() ) );
  129.                 }
  130.     
  131.                 // Volume name includes first '%20'.
  132.                 // Rework this for MacOS.
  133.                 loc = contents[ j ].indexOf( ( String )v.elementAt( l ) );
  134.     
  135.                 while ( ( loc > 0 ) && ( loc < contents[ j ].length() + 1 ) ) {
  136.                     String s1 = new String( contents[ j ].substring( 0, loc ) );
  137.                     String s2 = new String( contents[ j ].substring( loc + ( ( String )v.elementAt( l ) ).length() ) );
  138.                     contents[ j ] = new String( s1 + " " + s2 );
  139.                     loc = contents[ j ].indexOf( ( String )v.elementAt( l ) );
  140.                 }
  141.             }
  142.  
  143.             Image theImage;
  144.             int tempWidth = 0;
  145.             DesktopFrameItem d;
  146.             ImageIcon ii = new ImageIcon();
  147.             
  148.             if ( tempFile.isFile() ) {
  149.                 d = new DesktopDoc();
  150.                 ii = new ImageIcon( ( ( DesktopDoc )d ).getImage() );
  151.             }
  152.             else {
  153.                 d = new DesktopFolder();
  154.                 ii = new ImageIcon( ( ( DesktopFolder )d ).getImage() );
  155.             }
  156.  
  157.             d.setLabel( contents[ j ] );
  158.             d.setText( contents[ j ] );
  159.             d.setPath( this.getPath() + System.getProperty( "file.separator" ) + contents[ j ] );
  160.             d.setIcon( ii );
  161.             
  162.             d.setHorizontalAlignment( JLabel.CENTER );
  163.             d.setHorizontalTextPosition( JLabel.CENTER );
  164.             d.setVerticalTextPosition( JLabel.BOTTOM );
  165.             ii.setImageObserver( d );
  166.             p.add( d );
  167.         }
  168.  
  169. //
  170.  
  171.         p.setVisible( true );
  172.         
  173.         pane.getViewport().add( p, "Center" );
  174.         pane.setVisible( true );
  175.  
  176.         panel = new JPanel();
  177.         panel.setLayout( new BorderLayout() );
  178.         panel.add( pane, "Center" );
  179.         this.add( panel );
  180.         panel.reshape( this.getInsets().left, this.getInsets().top, this.getBounds().width - this.getInsets().right - this.getInsets().left, this.getBounds().height - this.getInsets().top - this.getInsets().bottom );
  181.         panel.setVisible( true );
  182.         this.pack();
  183.         this.validate();
  184.     }
  185.  
  186.     public void paint( Graphics g ) {
  187. //    public void paint( Graphics g2 ) {
  188.         g.setFont( this.getFont() );
  189.         FontMetrics theFontMetrics = g.getFontMetrics();
  190.  
  191.         if ( this.drag ) {
  192. //            g.setColor( Color.lightGray );
  193. //            g.fillRect( 0, 0, this.getBounds().width, this.getBounds().height );
  194.             g.setColor( Color.black );
  195.             g.drawRect( 0, 0, this.getBounds().width - 1, this.getBounds().height - 1 );
  196. //g2.drawImage( offscreenImage, 0, 0, this );
  197.             return;
  198.         }
  199.  
  200.         String defaultVolume = this.getPath();
  201.         
  202.         if ( defaultVolume == null )
  203.             return;
  204.         
  205.         File theDir = new File( defaultVolume );
  206.  
  207.         if ( !theDir.isDirectory() )
  208.             return;
  209.             
  210.         contents = theDir.list();
  211.         int tempLength = 0;
  212.  
  213.         if ( contents == null ) {
  214.             System.out.println( "contents == null" );
  215.             //return;
  216.         }
  217.         else
  218.             tempLength = contents.length;
  219.  
  220.         char pathSeparatorChar = theDir.pathSeparatorChar;
  221.         char separatorChar = theDir.separatorChar;
  222.  
  223.         g.setColor( Color.lightGray );
  224.  
  225.         int tempHeight = 20;
  226.  
  227.         g.fillRect( 0, 0, this.getBounds().width, this.getBounds().height );
  228.  
  229.         if ( this.isVisible() )
  230.             g.setColor( Color.black );
  231.  
  232.         // Content area
  233.         g.drawRect( 0, 0, this.getBounds().width + 1, this.getBounds().height + 1 );
  234.         
  235.         // Drop shadow border
  236.         g.fillRect( this.getBounds().width - 1, 0, 1, this.getBounds().height );
  237.         g.fillRect( 0, this.getBounds().height - 1, this.getBounds().width, 1 );
  238.  
  239.         // Close box
  240.         this.getCloseBox().setBounds( 5, 5, 10, 10 );
  241.         g.setColor( Color.lightGray );
  242.         g.fillRect( this.getCloseBox().getBounds().x, this.getCloseBox().getBounds().y, this.getCloseBox().getBounds().width, this.getCloseBox().getBounds().height );
  243.         g.setColor( Color.black );
  244.         g.drawRect( this.getCloseBox().getBounds().x, this.getCloseBox().getBounds().y, this.getCloseBox().getBounds().width, this.getCloseBox().getBounds().height );
  245.  
  246.         // Shade box
  247.         this.getShadeBox().setBounds( this.getBounds().width - 15, 5, 10,  10 );
  248.         g.setColor( Color.lightGray );
  249.         g.fillRect( this.getShadeBox().getBounds().x, this.getShadeBox().getBounds().y, this.getShadeBox().getBounds().width, this.getShadeBox().getBounds().height );
  250.         g.setColor( Color.black );
  251.         g.drawRect( this.getShadeBox().getBounds().x, this.getShadeBox().getBounds().y, this.getShadeBox().getBounds().width, this.getShadeBox().getBounds().height );
  252.         g.drawRect( this.getShadeBox().getBounds().x, this.getShadeBox().getBounds().y + ( this.getShadeBox().getBounds().height / 2 ) - 1, this.getShadeBox().getBounds().width, 2 );
  253.  
  254.         // Zoom box
  255.         this.getZoomBox().setBounds( this.getShadeBox().getBounds().x - 15, 5, 10,  10 );
  256.         g.setColor( Color.lightGray );
  257.         g.fillRect( this.getZoomBox().getBounds().x, this.getZoomBox().getBounds().y, this.getZoomBox().getBounds().width, this.getZoomBox().getBounds().height );
  258.         g.setColor( Color.black );
  259.         g.drawRect( this.getZoomBox().getBounds().x, this.getZoomBox().getBounds().y, this.getZoomBox().getBounds().width, this.getZoomBox().getBounds().height );
  260.         g.drawRect( this.getZoomBox().getBounds().x, this.getZoomBox().getBounds().y, this.getZoomBox().getBounds().width / 2, this.getZoomBox().getBounds().height / 2 );
  261.  
  262.         int endPoint = ( this.getBounds().width / 2 ) - ( theFontMetrics.stringWidth( this.getLabel() ) / 2 ) - 5;
  263.         int startH = this.getCloseBox().getBounds().width + 10;
  264.         int startV = this.getCloseBox().getBounds().y;
  265.         
  266.         // Draw lines in title bar
  267.         for ( int count = 0; count < 5; count++ ) {
  268.             g.setColor( Color.white );
  269.             g.drawLine( startH, startV, endPoint, startV );
  270.             endPoint += theFontMetrics.stringWidth( this.getLabel() ) + 10;
  271.             g.drawLine( endPoint, startV, this.getZoomBox().getBounds().x - 5, startV );
  272.             endPoint -= theFontMetrics.stringWidth( this.getLabel() ) + 10;
  273.             startV++;
  274.             g.setColor( Color.darkGray );
  275.             g.drawLine( startH, startV, endPoint, startV );
  276.             endPoint += theFontMetrics.stringWidth( this.getLabel() ) + 10;
  277.             g.drawLine( endPoint, startV, this.getZoomBox().getBounds().x - 5, startV );
  278.             endPoint -= theFontMetrics.stringWidth( this.getLabel() ) + 10;
  279.             startV++;
  280.         }
  281.  
  282.         // Volume name
  283.         g.drawString( this.getLabel(), ( this.getBounds().width / 2 ) - ( theFontMetrics.stringWidth( this.getLabel() ) / 2 ), this.getCloseBox().getBounds().y + this.getCloseBox().getBounds().height );
  284.  
  285.         if ( this.getShade() ) {
  286. //            g2.drawImage( offscreenImage, 0, 0, this );
  287.             return;
  288.         }
  289.             
  290.         startV = this.getCloseBox().getBounds().y + this.getCloseBox().getBounds().height + 5;
  291.  
  292.         // Draw interior
  293.         g.setColor( Color.white );
  294.         g.fillRect( this.getInsets().left, this.getInsets().top, this.getBounds().width - this.getInsets().right - this.getInsets().left - 1, this.getBounds().height - this.getInsets().top - this.getInsets().bottom - 1 );
  295.         g.setColor( Color.black );
  296.         g.drawRect( this.getInsets().left, this.getInsets().top, this.getBounds().width - this.getInsets().right - this.getInsets().left - 1, this.getBounds().height - this.getInsets().top - this.getInsets().bottom - 1 );
  297.  
  298.         // All else should get drawn.
  299.         g.setColor( Color.black );
  300.  
  301. //        panel.reshape( this.getInsets().left, this.getInsets().top, this.getBounds().width - this.getInsets().right - this.getInsets().left, this.getBounds().height - this.getInsets().top - this.getInsets().bottom );
  302. //        panel.paint( g );
  303. //        panel.repaint();
  304.     }
  305.  
  306.     public void adjustClipRect( Rectangle r ) {
  307.         this.getGraphics().clipRect( r.getBounds().x, r.getBounds().y, r.getBounds().width, r.getBounds().height );
  308.     }
  309. /*
  310.     public void update( Graphics g ) {
  311.         paint( g );
  312. //        panel.reshape( this.getInsets().left, this.getInsets().top, this.getBounds().width - this.getInsets().right - this.getInsets().left, this.getBounds().height - this.getInsets().top - this.getInsets().bottom );
  313. //        panel.paint( g );
  314. //        this.adjustClipRect( this.getBounds() );
  315.     }
  316. */
  317.     public Rectangle getTitleBar() {
  318.         return this.titleBar;
  319.     }
  320.  
  321.     public Rectangle getShadeBox() {
  322.         return this.shadeBox;
  323.     }
  324.  
  325.     public Rectangle getCloseBox() {
  326.         return this.closeBox;
  327.     }
  328.  
  329.     public Rectangle getZoomBox() {
  330.         return this.zoomBox;
  331.     }
  332.  
  333.     public Rectangle getUpArrowBox() {
  334.         return this.upArrowBox;
  335.     }
  336.  
  337.     public Rectangle getDownArrowBox() {
  338.         return this.downArrowBox;
  339.     }
  340.  
  341.     public Polygon getUpArrowPolygon() {
  342.         return this.upArrowPolygon;
  343.     }
  344.  
  345.     public Polygon getDownArrowPolygon() {
  346.         return this.downArrowPolygon;
  347.     }
  348.  
  349.     public void mouseDragged( MouseEvent e ) {
  350.         Desktop.setTopFrame( this );
  351.  
  352.         if ( this.drag ) {
  353.             Desktop.adjustClipRect( this.getBounds() );
  354.             this.setLocation( this.getBounds().x - this.initialX + e.getX(), this.getBounds().y - this.initialY + e.getY() );
  355.             repaint();
  356.         }
  357.         else if ( this.getResize() ) {
  358.             this.setSize( this.getBounds().width - this.resizeX + e.getX(), this.getBounds().height - this.resizeY + e.getY() );
  359.  
  360.             panel.reshape( this.getInsets().left, this.getInsets().top, this.getBounds().width - this.getInsets().right - this.getInsets().left, this.getBounds().height - this.getInsets().top - this.getInsets().bottom );
  361.             this.pack();
  362.             this.validate();
  363.             this.resizeX = e.getX();
  364.             this.resizeY = e.getY();
  365.  
  366.         }
  367.     }
  368.     
  369.     public void mouseMoved( MouseEvent e ) {
  370.     }
  371.     
  372.     public void mouseClicked( MouseEvent e ) {
  373.         if ( e.getClickCount() == 1 ) {
  374.             Desktop.setTopFrame( this );
  375.             this.repaint();
  376.         
  377.             if ( this.getCloseBox().contains( e.getPoint() ) ) {
  378.                 this.setVisible( false );
  379.                 this.repaint();
  380.                 Desktop.removeWindow( this );
  381.             }
  382.             else if ( this.getShadeBox().contains( e.getPoint() ) ) {
  383.                 if ( !this.getShade() ) {
  384.                     this.prevHeightShade = this.getBounds().height;
  385.                     this.setHeight( this.getCloseBox().getBounds().y + this.getCloseBox().getBounds().height + 5 );
  386.                     this.setShade( true );
  387.                 }
  388.                 else {
  389.                     if ( !this.getZoom() )
  390.                         this.setHeight( this.prevHeightShade );
  391.                     else
  392.                         this.setHeight( this.prevHeight );
  393.  
  394.                     panel.reshape( this.getInsets().left, this.getInsets().top, this.getBounds().width - this.getInsets().right - this.getInsets().left, this.getBounds().height - this.getInsets().top - this.getInsets().bottom );
  395.  
  396.                     this.pack();
  397.                     this.validate();
  398.  
  399.                     this.setShade( false );
  400.                 }
  401.  
  402.                 this.repaint();
  403.             }
  404.             else if ( this.getZoomBox().contains( e.getPoint() ) ) {
  405.                 Toolkit tk = Toolkit.getDefaultToolkit();
  406.                 Dimension d = tk.getScreenSize();
  407.                 // Set Window properties based on screen size.
  408.                 int res = tk.getScreenResolution();
  409.  
  410.                 if ( !this.getZoom() ) {
  411.                     this.prevX = this.getBounds().x;
  412.                     this.prevY = this.getBounds().y;
  413.                     this.prevWidth = this.getBounds().width;
  414.                     
  415.                     if ( this.getShade() )
  416.                         this.prevHeight = this.prevHeightShade;
  417.                     else
  418.                         this.prevHeight = this.getBounds().height;
  419.                         
  420.                     this.setBounds( 0, Global.defaultMenuBarHeight, d.width, d.height - Global.defaultMenuBarHeight );
  421.  
  422.                     panel.reshape( this.getInsets().left, this.getInsets().top, this.getBounds().width - this.getInsets().right - this.getInsets().left, this.getBounds().height - this.getInsets().top - this.getInsets().bottom );
  423.  
  424.                     this.pack();
  425.                     this.validate();
  426.                     this.setShade( false );
  427.                     this.setZoom( true );
  428.                 }
  429.                 else {
  430.                     if ( this.getShade() )
  431.                         this.setHeight( this.prevHeight );
  432.  
  433.                     this.setBounds( this.prevX, this.prevY, this.prevWidth, this.prevHeight );
  434.  
  435.                     panel.reshape( this.getInsets().left, this.getInsets().top, this.getBounds().width - this.getInsets().right - this.getInsets().left, this.getBounds().height - this.getInsets().top - this.getInsets().bottom );
  436.  
  437.                     this.pack();
  438.                     this.validate();
  439.                     this.setShade( false );
  440.                     this.setZoom( false );
  441.                 }
  442.  
  443.                 this.repaint();
  444.             }
  445.         }
  446.         else if ( e.getClickCount() == 2 ) {
  447.             Rectangle r = new Rectangle( 0, 0, this.getBounds().width, this.getCloseBox().getBounds().y + this.getCloseBox().getBounds().height + 5 );
  448. //            Rectangle r = new Rectangle( this.getBounds().x, this.getBounds().y, this.getBounds().width, this.getCloseBox().getBounds().y + this.getCloseBox().getBounds().height + 5 );
  449.             if ( r.contains( e.getPoint() ) ) {
  450.                 if ( !this.getShade() ) {
  451.                     this.prevHeightShade = this.getBounds().height;
  452.                     this.setHeight( this.getCloseBox().getBounds().y + this.getCloseBox().getBounds().height + 5 );
  453.                     this.setShade( true );
  454.                 }
  455.                 else {
  456.                     if ( !this.getZoom() )
  457.                         this.setHeight( this.prevHeightShade );
  458.                     else
  459.                         this.setHeight( this.prevHeight );
  460.  
  461.                     panel.reshape( this.getInsets().left, this.getInsets().top, this.getBounds().width - this.getInsets().right - this.getInsets().left, this.getBounds().height - this.getInsets().top - this.getInsets().bottom );
  462.  
  463.                     this.pack();
  464.                     this.validate();
  465.                     this.setShade( false );
  466.                 }
  467.  
  468.                 this.repaint();
  469.             }
  470.         }
  471.     }
  472.  
  473.     public void mouseEntered( MouseEvent e ) {
  474.     }
  475.         
  476.     public void mouseExited( MouseEvent e ) {
  477.     }
  478.         
  479.     public void mousePressed( MouseEvent e ) {
  480.         Desktop.setTopFrame( this );
  481.         
  482.         FontMetrics theFontMetrics = this.getGraphics().getFontMetrics(); 
  483.         this.titleBar.setBounds( this.getCloseBox().getBounds().x + this.getCloseBox().getBounds().width + 2, 0, this.getBounds().width - 8,  theFontMetrics.getHeight() );
  484.  
  485.         if ( this.getTitleBar().contains( e.getPoint() ) ) {
  486.             this.initialX = e.getX();
  487.             this.initialY = e.getY();
  488.             this.drag = true;
  489.             return;
  490.         }
  491.         
  492.         this.sizeBox.setBounds( this.getBounds().width - Global.defaultGrowBoxSize, this.getBounds().height - Global.defaultGrowBoxSize, Global.defaultGrowBoxSize, Global.defaultGrowBoxSize );
  493.  
  494.         if ( this.sizeBox.contains( e.getPoint() ) ) {
  495.             this.resizeX = e.getX();
  496.             this.resizeY = e.getY();
  497.             this.setResize( true );
  498.             return;
  499.         }
  500.     }
  501.  
  502.     public void mouseReleased( MouseEvent e ) {
  503.         if ( this.drag ) {
  504.             this.drag = false;
  505.             this.repaint();
  506.         }
  507.         else if ( this.getResize() ) {
  508.             this.setResize( false );
  509.             this.repaint();
  510.         }
  511.     }
  512.     
  513.     public String getPath() {
  514.         return this.path;
  515.     }
  516.     
  517.     public void setPath( String s ) {
  518.         this.path = s;
  519.     }
  520.  
  521.     public boolean getShade() {
  522.         return this.shade;
  523.     }
  524.     
  525.     public void setShade( boolean b ) {
  526.         this.shade = b;
  527.     }
  528.  
  529.     public boolean getZoom() {
  530.         return this.zoom;
  531.     }
  532.  
  533.     public void setZoom( boolean b ) {
  534.         this.zoom = b;
  535.     }
  536.  
  537.     public boolean getResize() {
  538.         return this.resize;
  539.     }
  540.  
  541.     public void setResize( boolean b ) {
  542.         this.resize = b;
  543.     }
  544.  
  545.     public void restoreHeight() {
  546.         if ( this.getShade() )
  547.             this.setHeight( this.prevHeightShade );
  548.     }
  549.  
  550.     public void setBounds( Rectangle r ) {
  551.         super.setBounds( r );
  552.         panel.reshape( this.getInsets().left, this.getInsets().top, r.width - this.getInsets().right - this.getInsets().left, r.height - this.getInsets().top - this.getInsets().bottom );
  553.     }
  554. }
  555.  
  556.