Getting the element of a vector in Java 2011View more random threads:
- Design Goals of Java for new course in 2011
- Send image to client over a socket in java 2011
- super.init(config) in java 2011
- JAVA Error 1714. The older version of Java cannot be removed
- 10 types or errors in java netbeans for beginners
- we can not call the non static methods from a sttic methods...
- Java working High-performance for all platforms
- New development in java 2011
- tutorial about the practical usage of the SQL 2011
- about DAO in java 2011
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)