Getting the element of a vector in Java 2011View more random threads:
- what are the latest updates for Java May 2011
- The basic concept of Java Virtual Machine & Runtime...
- Java Not Found or Not Working' occurs while playing Pogo...
- Sir how can we make java ".class" file as .exe file. So...
- Request for Guidance in java 20111
- Explain the difference between 2-tier and 3 tier client...
- How to include java classes
- Java Buzzwords (Vocabulary) for 2011
- what is boxing or unboxing and what is the uses of it in...
- Definition and introduction about java Libraries
Sponsored Links
}Code:private Vector<Integer> snakeX = new Vector<Integer> (5,2); private Vector<Integer> snakeY = new Vector<Integer> (5,2); public void startGraphics (){ this.addKeyListener(this); repaint(); snakeX.add(240); snakeY.add(240); snakeX.add(240); snakeY.add(230); snakeX.add(240); snakeY.add(220); } public void paintComponent (Graphics g){ super.paintComponent (g); for (int x : snakeX){ g.fillOval(x, snakeY.elementAt(snakeX.lastIndexOf (x)),10, 10); System.out.println ("x: " + x + "\t y: " + snakeY.elementAt(snakeX.lastIndexOf (x))); }
There are currently 1 users browsing this thread. (0 members and 1 guests)