Equivalent of CreateHatchBrush() i.e. drawing grid

I want to draw a rectangle that contains a grid (mesh) in it. How this can be acheived.Something equivalent to what we get using CreateHatchBrush(HS_DIAGCROSS, clref) in MFC.
[188 byte] By [vinu.1001a] at [2007-10-3 8:34:55]
# 1
See the TexturePaint class.
itchyscratchya at 2007-7-15 3:42:27 > top of Java-index,Desktop,Core GUI APIs...
# 2
Thanks, but I am not getting the exact look which I need. I am unable to get the lines in grid crossing each other diagonally. Can this be acheived?
vinu.1001a at 2007-7-15 3:42:27 > top of Java-index,Desktop,Core GUI APIs...
# 3

Swing labs has a neat pinstripe painter which would fit the bill. It's really simple to use.

public class SomePanel extends JXPanel{

JXPanel(){

PinstripePainter pinstripe1 = new PinstripePainter( new Color( 255, 255, 255, 80 ), 0.0 );

pinstripe1.setSpacing( 5 );

pinstripe1.setStripeWidth(2);

PinstripePainter pinstripe2 = new PinstripePainter( new Color( 255, 255, 255, 80 ), 45.0 );

pinstripe2.setSpacing( 5 );

pinstripe2.setStripeWidth(2);

this.setBackgroundPainter( new CompoundPainter( pinstripe1, pinstripe2 ) );

}

http://swinglabs.org/index.jsp

Saevena at 2007-7-15 3:42:27 > top of Java-index,Desktop,Core GUI APIs...
# 4
I am unable to get the lines in grid crossing each other diagonally. Can this be acheived?You just render a small image with grid lines crossing diagonally and it will be used for the painting. When you say, 'unable,' what's going wrong?
itchyscratchya at 2007-7-15 3:42:27 > top of Java-index,Desktop,Core GUI APIs...
# 5
Thanks for your input.yes, rendering image is an simple option but I have a restriction of not using this. I have to achieve it using some other method. TexturePaint class give me similar looks but not exact one.
vinu.1001a at 2007-7-15 3:42:27 > top of Java-index,Desktop,Core GUI APIs...
# 6

rendering image is an simple option but I have a restriction of not using this. I have to achieve it using some other method. TexturePaint class give me similar looks but not exact one

...?

I'm not talking about rendering what you want as an image. You create an image which is used by TexturePaint. eg to create a diagonal grid you might create a 5x5 grid and render an 'X' on it like this,

##

-#-#-

--#--

-#-#-

##

Then when you render anything using that paint, this will be tiled onto the shape.

If you want to do it another way, take the shape you're trying to draw and use it as the clip for the Graphics2D object, and then just paint whatever you want over it.

itchyscratchya at 2007-7-15 3:42:27 > top of Java-index,Desktop,Core GUI APIs...