Moveable menu selection box

I’m trying to implement a 3D pause menu and I’d like it to work like this: Once in the menu, the top menu object is highlighted (using a lighter material colour). The user can control this highlight on the joypad with DPAD joystick up + down, then a button press activates that object.

I have the menu implemented and working with the mouse - as the mouse moves over the menu items they highlight, and when the user clicks on them they do what they should, my problem is I don’t know how to have the selection move up + down on the DPAD/joystick.

I’m tearing my hair out here, is this even possible? Can anyone show me how this would work in java please?

If I understand the question, this is the solution in pseudocode.

int totalMenu = 10;
int currentMenu = 0;

if(joyUp) currentMenu = (currentMenu + 1) % totalMenu;
if(joyDown) currentMenu = (currentMenu - 1) % totalMenu;

switch(currentMenu)
{
case 0 : top menu

case 9 : bottom menu
}

So basically you specify the number of menu options, assign current menu to the top one (or whatever one your mouse is pointing to), then test for Joy inputs, switch to the next menu index, use conditionals to activate a menu. The % (modulo) should make sure your selection loops from bottom to top if you go to far down, and reverse.