Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def addMouseScroll[A](comboBox: JComboBox[A]): Unit = {
- comboBox.addMouseWheelListener(new MouseAdapter {
- override def mouseWheelMoved(e: MouseWheelEvent): Unit = {
- val itemCount = comboBox.getItemCount
- val index = comboBox.getSelectedIndex + e.getWheelRotation
- val newIndex = if (index < 0 ) itemCount + index else index % itemCount
- comboBox.setSelectedIndex(newIndex)
- }
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement