From c43642cb83c620edb65c77a8b2340ce6ffee5f2a Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Thu, 10 Nov 2005 17:53:14 +0000 Subject: [PATCH] Add mousewheel listener --- src/MCview/PDBCanvas.java | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) 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); -- 1.7.10.2