How to make JScrollPane scroll 1 line per mouse wheel step?

前端 未结 2 769
独厮守ぢ
独厮守ぢ 2021-01-05 17:05

I have a JScrollPane whose content pane is a JXList. When I use the mouse wheel on the list, the list steps three (3) items at a time. This also works for a table, regardles

2条回答
  •  醉话见心
    2021-01-05 18:08

    Too much code for a simple explanation:

    JLabel lblNewLabel = new JLabel("a lot of line of text...");
    JScrollPane jsp = new JScrollPane(lblNewLabel);
    jsp.getVerticalScrollBar().setUnitIncrement(10); //the bigger the number, more scrolling
    frame.getContentPane().add(jsp, BorderLayout.CENTER);
    

提交回复
热议问题