Getting the element of a vector in Java 2011View more random threads:
- What about Java as a programming language for...
- execution of programms in java
- KeyPress Event Handlers in java
- what is difference between PhP and java
- JAVA Download errors: 1305, 2755, 1606, etc.
- What is different between JAVA and JavaScript? Is it same...
- Java forum for usa students 2011 for helping
- What does constructor do in class?Why we use copy...
- J2EE and JDK Path Setting why you recive the deployment...
- Java is Very similar C/C++ syntax, operators, 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)