• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

GeneralPath don't works  RSS feed

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have used the GeneralPath Class to draw a path, but nothing appears on the screen...
If I draw with the Line2D Class everythings seems to be fine...
Does anyone sees some failure in my Code ? :

class CurvePanel extends JPanel {

GeneralPath path = new GeneralPath();

public CurvePanel() {
setBackground(Color.white);
}

protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.draw((Shape)path);
}

public void addCurve(Vector v) {
int[] x = new int[v.size()+1];
int[] y = new int[v.size()+1];
int i = 0;

for (Iterator iter = v.iterator(); iter.hasNext() {
Point p = (Point) iter.next();
x[i] = (int) p.getX();
y[i] = (int) p.getY();
i++;
}

for(int u=1;u<i;u++) {
path.moveTo(x[u], y[u]);
}
repaint();
}
}

Even if I close the Path, there is no effect.
DoI have to close my Path?
[ July 30, 2004: Message edited by: Raschin Ghanad ]
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!