java - CardLayout: Find out if current Item is first/last in list -


i use cardlayout , want use 2 buttons .next() , .previous() scroll through items. works great 1 problem: want stop scrolling if current item first/last item.

i can't find method index of current item or flag find out wether current item first/last or not.

can tell me simple way find out if current item first/last?

since there methods .first() , .last() jump, guessed there must method find out if current first/last.

i use list<string> containing names of components in card layout, , field containing index of displayed component.

to know if you're @ beginning, test if index == 0. know if you're @ last component, test if index == list.size() - 1. show next component, use index++; layout.show(parent, list.get(index));.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -