Results 1 to 4 of 4

Thread: Graphics in java

  1. #1

    Thread Starter
    Member daveyboy's Avatar
    Join Date
    Feb 2002
    Location
    Aberystwyth, UK
    Posts
    33

    Graphics in java

    Does anyone know of any tutorials or have any hints for using Graphics, I keep trying to use them, and I think that there might be something I'm missing out on, I usually end up with ImageIcons but that's not what I want at all


    Infinity isn't large it's just incomprehensible

  2. #2
    Addicted Member Mrs Kensington's Avatar
    Join Date
    Sep 2001
    Location
    Dorset, UK
    Posts
    144
    I normally use Graphics when i've extended JComponent or something like that. You then overide the paint method. That paint method is called whenever the component needs to be repainted and has a graphics object passed to it.
    You can then paint using the Graphics functions like drawLine and fillRect and this paints straight onto the component.

    You can also get the graphics object of an Image which allows you to draw straight onto the image.

    Hope that helps!
    Ford? Theres an infinite number of monkeys outside that want to talk to you about a script of hamlet they've produced!

  3. #3

    Thread Starter
    Member daveyboy's Avatar
    Join Date
    Feb 2002
    Location
    Aberystwyth, UK
    Posts
    33
    It does indeed.....

    I was really have problems with the updates within swing, because of swing being run in a seperate thread, and java using off screen buffering, does anyone know how to stop java using the offscreen buffer, or how to force a redisplay?


    Infinity isn't large it's just incomprehensible

  4. #4
    Addicted Member Mrs Kensington's Avatar
    Join Date
    Sep 2001
    Location
    Dorset, UK
    Posts
    144
    AWT doesn't use off screen buffering (does it?) so you could use Window of Frame instead of JFrame or JWindow. You normally ask for a redisplay using repaint() but that doesn't force it. That asks the Swing thread to repaint it next time it can so you can never rely on it.

    There is a way to completely control the rendering of Windows but this is only useful if you want full control of the controls painting.
    I use this when i'm writing games as you dont want to rely on Swing to do the painting. If the above information doesn't help post again and i'll put up details about the other way.
    Ford? Theres an infinite number of monkeys outside that want to talk to you about a script of hamlet they've produced!

Posting Permissions

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



Click Here to Expand Forum to Full Width