続き
public void mousePressed(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1) { // 左クリックされた時
currentChoice--;
if (currentChoice < start) { // when choice gets below the starting index
start = currentChoice;
if (currentChoice < 0) { // 一番上に来たら初期化
currentChoice = 0;
start = 0;
}
}
} else if (e.getButton() == MouseEvent.BUTTON3) { // 右クリックされた時
System.out.println("DOWN");
currentChoice++;
if (currentChoice > displaySize - 1) {
System.out.println(start + 1 + displaySize );
if (start + displaySize < elementList.length) {
start++;
}
if (currentChoice > elementList.length - 1) { // 一番下に来た
currentChoice = elementList.length - 1;
}
}
}
}