// @topic T11732 2D Graphics demo 02 -- scratch pad designer // @brief class <tt>D2Canvas</tt> implements <tt>JPanel</tt> /* * D2Canvas.java * * Created on Mar 26, 2013, 11:01:49 AM */ package shopsimulation; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.geom.Rectangle2D; public class D2Canvas extends javax.swing.JPanel { boolean debugFlag = false; /** Creates new form D2Canvas */ public D2Canvas() { initComponents(); } @Override public void paint( Graphics gr ) { super.paint( gr ); /* if ( debugFlag == true ) { debugFlag = false; return; } else { debugFlag = true; } */ Graphics2D gr2d = ( Graphics2D ) gr; Rectangle rect = this.getBounds(); gr2d.draw( new Rectangle2D.Double( rect.getX() + 10, rect.getY() + 10, rect.getWidth() - 20, rect.getHeight() - 20 ) ); //gr2d.draw( new Rectangle2D.Float( 40, 40, 175, 190 ) ); //gr2d.draw( new Line2D.Float( 40, 40, 40+175, 40+190 ) ); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 400, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 300, Short.MAX_VALUE) ); }// </editor-fold>//GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables // End of variables declaration//GEN-END:variables }