Getting the element of a vector in Java 2011View more random threads:
- How to extract objects in a video shot in java 2011
- Java working High-performance for all platforms
- Design Goals of Java for new course in 2011
- is java a throughly OOP
- What is perl and What is a "sandbox
- NetBeans IDE 7.0 Download Started in 2011 for beginners
- Why it is not working "CmdLineArgsApp.class"
- Send image to client over a socket in java 2011
- need explanation in java 2011
- what are the latest updates for Java May 2011
}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))); }
Sponsored Links
There are currently 1 users browsing this thread. (0 members and 1 guests)