Results 1 to 2 of 2

Thread: Zoom in and out

  1. #1
    mickey is offline Member
    Join Date
    Jun 2010
    Rep Power

    Default Zoom in and out


    I am working on a Java project, based on calibrations, I generate a graph for which I need to implement the feature Zoom in and out. I must make it enlarge and small when the mouse scroll / wheel is moved up and down, or provide an option to enlarge when it is doubled clicked (like how it appears in windows image viewer)

    Is this feasible to do. Could someone share their thoughts on this, so that I can get started.


  2. #2
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    San Jose, CA, USA
    Rep Power


    It can be done by listening for the mouse, keeping track of the clicks or scroll wheel position (zoom level). In your JPanel paintComponent(...) you can set the draw scale.

    Java Code:
    public void paintComponent(Graphics g) {
       double scale = 1.0; //put your zoom level calc here
       Graphics2D g2d = (Graphics2D)g;
       //draw stuff
    Last edited by mrmatt1111; 06-15-2010 at 11:46 PM.
    My Hobby Project: LegacyClone

Similar Threads

  1. Zoom on graphic
    By onephenom in forum Java 2D
    Replies: 1
    Last Post: 03-24-2010, 09:52 PM
  2. Java Zoom in and Zoom out?
    By ps20090 in forum Java Applets
    Replies: 2
    Last Post: 09-18-2009, 12:04 PM
  3. how to zoom using slider
    By kumar_gemi in forum New To Java
    Replies: 0
    Last Post: 07-11-2009, 10:06 PM
  4. Help with zoom in java
    By cachi in forum Enterprise JavaBeans (EJB)
    Replies: 3
    Last Post: 08-07-2008, 03:01 PM
  5. zoom in swing
    By Alan in forum AWT / Swing
    Replies: 2
    Last Post: 05-31-2007, 02:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts