import java.awt.*; class JFig { static enum Action { FILL, STROKE }; int x[]; int y[]; float lineWidth; Action action; JFig( int x1[], int y1[], float w, Action act ) { x = x1; y = y1; lineWidth = w; action = act; } void drawSelfInGraphics( Graphics2D g2d ) { g2d.setStroke( new BasicStroke( lineWidth ) ); if( action == Action.STROKE ) g2d.drawPolyline( x, y, x.length ); else g2d.fillPolygon( x, y, x.length ); } }