Results 1 to 5 of 5
  1. #1
    jazzermonty is offline Member
    Join Date
    Jan 2011
    Posts
    71
    Rep Power
    0

    Default question on arguments for painting components

    Hi folks, been a while. Here's my question. I want to paint components onto a JPanel that I can make their behaviour independent. I want to use different methods to do this. Here's an example code:

    Java Code:
    package myPaCKAGE;
    
    import java.awt.Color;
    import java.awt.Graphics;
    
    public class image
    {
    
        private int width, height;
        private Object square;
    
        public Picture(int width, int height)
        {
            this.width = width;
            this.height = height;
            this.square();
        }
       
        }
        public void square(Graphics g)
        {
            g.drawRect(10, 10,10, 10);
            g.setColor(Color.red);
        }     
    }
    Question is what do I pass as an argument on the line:
    Java Code:
    this.square();
    so that I can invoke the method to create the object?

    Thanks

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: question on arguments for painting components


  3. #3
    jazzermonty is offline Member
    Join Date
    Jan 2011
    Posts
    71
    Rep Power
    0

    Default Re: question on arguments for painting components

    Thanks doWhile, just the job.

  4. #4
    jazzermonty is offline Member
    Join Date
    Jan 2011
    Posts
    71
    Rep Power
    0

    Default Re: question on arguments for painting components

    doWhile

    If you do happen across this thread again, can I just say a hugh thank you. That tutorial is just the ticket and I've managed to do more in the last 15 minutes than the whole of last night. Is your google foo strong or do you know the tuorials that well? I searched and searched last night and didn't come across this. I'll leave this thread open for another hour or so to see if you return before marking as closed. Once again I can't thank you enough.

    Cheers

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default Re: question on arguments for painting components

    Is your google foo strong or do you know the tuorials that well?
    Search this forum for "Performing Custom Painting"

    Spend a little time each day reading the forums and you may never have to ask a question of your own. It's all there, several times over.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 2
    Last Post: 02-22-2012, 09:43 AM
  2. New To Java: Question about arguments
    By Humphrey Bogart in forum New To Java
    Replies: 5
    Last Post: 02-10-2012, 06:27 PM
  3. Replies: 8
    Last Post: 09-23-2010, 12:07 AM
  4. question about painting efficiently
    By gib65 in forum AWT / Swing
    Replies: 16
    Last Post: 07-04-2010, 08:18 PM
  5. Swing components vs. custom painting
    By Cruncher in forum New To Java
    Replies: 6
    Last Post: 05-06-2010, 07:16 AM

Posting Permissions

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