From: amwaterhouse Date: Thu, 10 Nov 2005 17:53:14 +0000 (+0000) Subject: Add mousewheel listener X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c43642cb83c620edb65c77a8b2340ce6ffee5f2a;p=jalview.git Add mousewheel listener --- diff --git a/src/MCview/PDBCanvas.java b/src/MCview/PDBCanvas.java index ccb1643..7b6021d 100755 --- a/src/MCview/PDBCanvas.java +++ b/src/MCview/PDBCanvas.java @@ -159,6 +159,27 @@ public class PDBCanvas extends JPanel implements MouseListener, MouseMotionListe addMouseMotionListener(this); addMouseListener(this); + addMouseWheelListener(new MouseWheelListener() + { + public void mouseWheelMoved(MouseWheelEvent e) + { + if (e.getWheelRotation() > 0) + { + scale = (float) (scale * 1.1); + redrawneeded = true; + repaint(); + } + + else + { + scale = (float) (scale * 0.9); + redrawneeded = true; + repaint(); + } + } + }); + + findCentre(); findWidth(); @@ -504,8 +525,8 @@ public class PDBCanvas extends JPanel implements MouseListener, MouseMotionListe return prefsize; } - public void keyPressed(KeyEvent evt) { - int key = evt.getKeyChar(); + public void keyPressed(KeyEvent evt) + { if (evt.getKeyCode() == KeyEvent.VK_UP) { scale = (float) (scale * 1.1);