Hi.

I'm not sure what do you want to do, but I changed your code so it now draws the pentagon and fills it with

pattern of green hexagones.

You can play with sizes, shapes and colors.

Hope it helps.

Best regards.

Polina

/*

* MyPoly7A.java

*

* Created on April 21, 2004, 2:59 PM

*/

/**

*

* @author dbraxton

*/

//

java packages are imported

import java.awt.*;

import java.awt.event.*;

import java.awt.geom.*;

import java.awt.image.BufferedImage;

import java.io.*;

import javax.imageio.ImageIO;

import javax.swing.*;

// Graphics2D component

class MyPoly7A extends JPanel

{ public MyPoly7A()

{

setBackground( Color.red );

}

protected void paintComponent ( Graphics g )

{

super.paintComponent ( g );

Graphics2D g2d = ( Graphics2D ) g;

//g2.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );

int width = getWidth ( );

int height = getHeight ( );

int cx = width / 2;

int cy = height / 2;

int dia = Math.min ( width, height ) / 4;

int strut = Math.min ( width, height ) * 3/4;

g2d.setPaint ( Color.blue );

g2d.draw ( new Rectangle2D.Double ( width / 16, height / 16, width * 7/8, height * 7/8 ) );

int R = ( int )( strut / (4 * Math.cos(Math.PI/5) * Math.sin( Math.PI / 5 ) ) );

int[ ] [ ] xy = generateShapeArrays( R, 5, cx, cy );

Polygon pentagon = new Polygon( xy [ 0 ], xy [ 1 ], 5);

g2d.setPaint( Color.white );

g2d.draw( pentagon );

// TROUBLE STARTS HERE LINE 47 follows

BufferedImage buffi = new BufferedImage(15, 15, BufferedImage.TYPE_INT_RGB);

Graphics2D buffig = buffi.createGraphics();

buffig.setColor(Color.white);

Rectangle textureRect= new Rectangle(0, 0, 15, 15);

buffig.fill(textureRect);

buffig.setColor(Color.green);

int[ ] [ ] xyp = generateShapeArrays(textureRect.height/2, 6, textureRect.x+textureRect.width/2, textureRect.y+textureRect.height/2);

Polygon smallHexagon = new Polygon( xyp [ 0 ], xyp[ 1 ], 6);

buffig.fill(smallHexagon);

Rectangle r = new Rectangle(0,0,25,25);

g2d.setPaint(new TexturePaint(buffi, r));

g2d.fill(pentagon);

}

private int [ ] [ ] generateShapeArrays(int R, int sides, int cx, int cy)

{

int[ ] x = new int[sides];

int[ ] y = new int[sides];

int radInc = 0;

if (sides % 2 == 0)

radInc = 1;

for(int counter = 0; counter < sides; counter++)

{

x [ counter ] = cx + ( int ) ( R * Math.sin ( radInc * Math.PI / sides ) );

y [ counter ] = cy - ( int ) ( R * Math.cos ( radInc * Math.PI / sides ) );

radInc += 2;

}

return new int[ ][ ]

{

x, y

};

}

}