sc = wi.getScaledInstance(puzpiece.getWidth()/3,puzpiece.getHeight()/3, Image.SCALE_AREA_AVERAGING);. The problem itself is quite simple: the Panel does not yet have a size since the frame has not been packed and is not yet visible.
I'm not sure what the best way to do this would be, but what would probably work is to hook an ancestor listener into the panel. This way it'll trigger an ancestorMoved event immediately upon displaying the frame. You should then be able to do what you want to do with the images, and then repaint the panel again.
Yeah that should work methinks.
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php