Results 1 to 2 of 2
  1. #1
    jwl
    jwl is offline Member
    Join Date
    Jul 2012
    Posts
    93
    Rep Power
    0

    Default help with Graphics 2D

    Here is my code:

    Java Code:
    public void paint(Graphics g) {
            Graphics2D g2d  = (Graphics2D) g;
            if (imageBuffer != null)
                g2d.drawImage(imageBuffer, insets.left, insets.top, null);
    }
        
        
        private void drawGame() {
            g.drawRect(0, 0, 200, 200);
            for (int i = 0; i < 8; i++) {            
                    g.translate(15, 15);
                    g.drawRect(0, 0, 200, 200);            
            }     
            repaint();
        }
    What I want to do is use g2d variable in the drawGame() method so I can save rectangle in a variable "rec" and do g2d.draw(rec);
    so I don't have to change the coordinates or distance values twice.

  2. #2
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: help with Graphics 2D

    Ok great - what's your question?

Similar Threads

  1. Graphics 2D
    By scopene in forum Java 2D
    Replies: 0
    Last Post: 03-26-2012, 02:21 AM
  2. Drawing a graphics onto another Graphics ?
    By Ziden in forum Java Applets
    Replies: 0
    Last Post: 01-08-2011, 08:30 PM
  3. How to use graphics
    By Mattedatten in forum New To Java
    Replies: 3
    Last Post: 03-18-2010, 03:10 PM
  4. Help me with graphics
    By 7oclock in forum New To Java
    Replies: 12
    Last Post: 04-05-2009, 12:20 AM
  5. Help with 2d graphics please
    By xbox_nutter in forum New To Java
    Replies: 0
    Last Post: 04-02-2009, 12:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •