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 7810859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:56:54+00:00 2026-06-02T03:56:54+00:00

I am trying to implement a zoom-in function. And my current problem is: Every

  • 0

I am trying to implement a zoom-in function.

And my current problem is: Every time I clicked zoom-in, a new zoomed image would appear on the panel. But the original image is still on the panel. So I tried using the repaint method. The problem is, I can see the new image flashed on the screen and then disappears. Am I using the code in the wrong way?
Currently the code is like this:

Double click to zoom in:

    panel_Show.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent arg0) {
            // TODO Auto-generated method stub
            int count = arg0.getClickCount();
            if (count == 2 && !arg0.isConsumed()) {
                int x = arg0.getX();
                int y = arg0.getY();
                zoomin(x, y);
            }
        }

The zoom in method:

    protected void zoomin(int x, int y) {
    if (allowZoomIn && zoomLevel < zoomLimit) {
        zoomLevel = zoomLevel + 1;
        int width = panel_Show.getWidth();
        int height = panel_Show.getHeight();
        centerX = centerX - (width/2 - x)/alpha;
        centerY = centerY - (height/2 - y)/alpha;
        alpha = alpha * zoomLevel;
        paintSpace(zoomLevel);
    }
}

Painting the points:

   protected void paintSpace(int level) {
    panel_Show.repaint();
    pointDrawer = (Graphics2D) panel_Show.getGraphics();

    Iterator<Integer> keyIterator = xCordTable.keySet().iterator();
    while (keyIterator.hasNext()) {
        int id = keyIterator.next();
        double xcord = xCordTable.get(id);
        double ycord = yCordTable.get(id);
                    //below is just some logic code to control how to paint points
        int size = freqTable.get(id);
        paintStar(xcord, ycord, Color.BLUE, size * level);
    }
}
  • 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-06-02T03:56:55+00:00Added an answer on June 2, 2026 at 3:56 am

    You have to use panel.remove(image) to remove the original image. You got to then add a new image and then repaint()

    Suggestion for zooming i will rather use a CardLayout and keep the original image safe in one card

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

Sidebar

Related Questions

I'm trying to implement an image zoom effect, a bit like how the zoom
Ok well I'm trying implement something similar to the 'undo' function in many image
I am using the visualisation arborjs and I am trying to implement the zoom-function.
I'm trying to implement JavaScript based image zoom feature similar to the ones mentioned
I'm trying to implement a simple zoom to point functionality in WinForms. When the
I am trying implement Unblock me Puzzle. i want to change image position from
I am trying to implement multi touch zoom in and zoom out functionality to
I have been trying to implement pinch zoom/in-out for PhotoView (a UIImageView instance) using
I am trying to implement the map showing the current location with the path.
I am trying to implement pinch zoom and it is working but when i

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.