Click to See Complete Forum and Search --> : Graphics in java
daveyboy
Mar 21st, 2002, 10:36 PM
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
Mrs Kensington
Mar 22nd, 2002, 06:46 AM
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!
daveyboy
Mar 26th, 2002, 06:32 PM
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?
Mrs Kensington
Mar 28th, 2002, 06:05 AM
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.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.