Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7519945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:59:03+00:00 2026-05-30T01:59:03+00:00

I think the question is quite self-explanatory. I want to implement a simple zoom

  • 0

I think the question is quite self-explanatory. I want to implement a simple zoom function using a JSlider like in Windows Live Photo Gallery for instance.

I’ve had a quick look online but all the code I’ve tried to use appears to have errors when I copy it into Eclipse. I don’t really want to use a third-party library either as the application may be sold under a company name. Plus, I’m beginning to realise that there may be some safety precautions required in order to prevent errors, but I do not know what these will be.

So, if anybody can provide me with some Java code to zoom in and out of images it would be greatly appreciated.

P.S. I plan to use the Image as an ImageIcon inside of a JLabel which will be added to a JScrollPane.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:59:04+00:00Added an answer on May 30, 2026 at 1:59 am

    You can easily achieve this by using scale transforms on the original image.
    Assuming your the current image width newImageWidth, and the current image height newImageHeight, and the current zoom level zoomLevel, you can do the following:

    int newImageWidth = imageWidth * zoomLevel;
    int newImageHeight = imageHeight * zoomLevel;
    BufferedImage resizedImage = new BufferedImage(newImageWidth , newImageHeight, imageType);
    Graphics2D g = resizedImage.createGraphics();
    g.drawImage(originalImage, 0, 0, newImageWidth , newImageHeight , null);
    g.dispose();
    

    Now, replace the original image, originalImage, in your display area by resizedImage.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My question is quite simple (I think and hope). I would like to know
Using Rails 3.1.1. & 'rails3-jquery-autocomplete' I think this question should be quite simple for
I think the question is self explanatory. If I declare a property of a
My question is I think quite simple but I don't think the answer will
I think my question is quite simple, but I can't find a solution. I
I can't quite think of how to phrase the question to be precise, but
I think the question is pretty simple, do I need all the rest of
I think the question title seems to explain eveything. I want to detect whether
The title of this question may be a bit misleading. I couldn't quite think
The question is quite simple: how do I capture and redirect to a file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.