Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. def addMouseScroll[A](comboBox: JComboBox[A]): Unit = {
  2. comboBox.addMouseWheelListener(new MouseAdapter {
  3. override def mouseWheelMoved(e: MouseWheelEvent): Unit = {
  4. val itemCount = comboBox.getItemCount
  5. val index = comboBox.getSelectedIndex + e.getWheelRotation
  6. val newIndex = if (index < 0 ) itemCount + index else index % itemCount
  7.  
  8. comboBox.setSelectedIndex(newIndex)
  9. }
  10. })
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement