3

According to How to use my trackpad for horizontal mousewheel scrolling in a Java AWT ScrollPane, one should be able to scroll horizontally via a Trackpoint. But it works only vertically for me. I'm using Debian Wheezy, and tried it with OpenJDK 1.7 and Sun Java 6. Here is the MWE (from the above link)

import java.awt.*;
import javax.swing.*;

public class ScrollExample extends JPanel { 

        public void paint(Graphics g) {

                super.paint(g);

                g.setColor(Color.green);
                g.fillOval(0,0,400, 400);

        }

        public static void main(String[] args) {

                JFrame f = new JFrame ("Scroll Example");
                ScrollExample p = new ScrollExample();
                p.setPreferredSize(new Dimension(1000, 1000));

                JScrollPane scroller = new JScrollPane(p,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
                scroller.getHorizontalScrollBar().setUnitIncrement(10);
                scroller.getVerticalScrollBar().setUnitIncrement(10);

                f.setPreferredSize(new Dimension(500,500));
                f.add (scroller,BorderLayout.CENTER);
                f.pack();
                f.show();
        }
}
Community
  • 1
  • 1
Thomas Rebele
  • 374
  • 3
  • 11
  • Does it show the scrollbar when you resize a frame? – Roman C Sep 21 '12 at 18:02
  • @Roman C: Yes, the scrollbar is always shown, but that's not my problem. Scrolling with 'Mouse click&hold on horizontal Scrollbar, than move left and right' works also. The only issue is, that holding the middle mouse button while moving my trackpoint right and left doesn't scroll horizontally (it does nothing at all). But scrolling horizontally with the Trackpoint works in all other Applications. – Thomas Rebele Sep 21 '12 at 19:47
  • unrelated: always override paintComponent (instead of paint) for custom painting – kleopatra Sep 22 '12 at 10:29

0 Answers0