Write a keyPressed method that behaves as follows. If the user presses the up arrow, the method should output "You pressed up" using the System.out.println method. If the user presses the down arrow, the method should output "You pressed down" using the System.out.println method.

What will be an ideal response?


```
public void keyPressed(KeyEvent event) {
switch(event.getKeyCode()) {
case KeyEvent.VK_UP:
System.out.println("You pressed up.");
break;
case KeyEvent.VK_DOWN:
System.out.println("You pressed down.");
break;
}//end switch
}//end method
```

Computer Science & Information Technology

You might also like to view...

What is a base class?

A. A general class. B. Special case of the derived class. C. Polymorphism. D. All of the above.

Computer Science & Information Technology

Structures can contain other structures, and they can be contained in other structures. They can also overlap.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

________ is a Windows 8 program used to create drawings and open digital pictures

Fill in the blank(s) with correct word

Computer Science & Information Technology

Use the ____ dialog box to create a new template.

A. Template B. New C. New Template D. Create Template

Computer Science & Information Technology