curveTo....help

hi ,i want simple example of "curveTo" (java.awt.geom.GeneralPath)
[80 byte] By [vivinda] at [2007-11-27 6:12:19]
# 1

import java.awt.*;

import java.awt.geom.GeneralPath;

import javax.swing.*;

public class CurvingPath extends JPanel {

GeneralPath path;

public CurvingPath() {

initPath();

}

protected void paintComponent(Graphics g) {

super.paintComponent(g);

Graphics2D g2 = (Graphics2D)g;

g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,

RenderingHints.VALUE_ANTIALIAS_ON);

g2.setPaint(Color.blue);

g2.draw(path);

}

private void initPath() {

int[] coords = {

150, 150, 230, 75, 200, 275, 350, 350

};

path = new GeneralPath();

path.moveTo(coords[2], coords[3]);

path.lineTo(coords[0], coords[1]);

path.curveTo(80.4f, 215.2f, 80.4f, 215.2f,

coords[4], coords[5]);

path.lineTo(coords[6], coords[7]);

}

public static void main(String[] args) {

JFrame f = new JFrame();

f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

f.getContentPane().add(new CurvingPath());

f.setSize(400,400);

f.setLocation(200,200);

f.setVisible(true);

}

}

crwooda at 2007-7-12 17:19:25 > top of Java-index,Security,Cryptography...
# 2
That help me lot
vivinda at 2007-7-12 17:19:25 > top of Java-index,Security,Cryptography...