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

  • Home
  • SEARCH
  • 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 9004079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:49:16+00:00 2026-06-16T00:49:16+00:00

I have a Java swing application where I’ve created an ImageIcon with a picture

  • 0

I have a Java swing application where I’ve created an ImageIcon with a picture and displayed it to a screen. I did that by loading a URL as an ImageIcon and placing it in the Java Swing window as a label.

Now I need to place ‘markers’ on the image with other images.
In context: Place a picture of an eye on someones face over their eye.

I’d appreciate anyone who can point my in the right direction or give me some SSCCE code to work from.

What is the best manner to place ‘markers’ on an ImageIcon Java Swing?

  • 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-16T00:49:17+00:00Added an answer on June 16, 2026 at 12:49 am

    The basic concept is, you need a temporary image onto which you can paint the master/base image and the marker.

    1. Create a new BufferedImage. This would typically be the same size as the master image, but doesn’t have to be.
    2. Paint the master image onto BufferedImage
    3. Paint the marker onto the BufferedImage
    4. Create a new ImageIcon using the BufferedImage
    5. Apply the ImageIcon to the label…

    enter image description hereenter image description hereenter image description here

    public class PaintIcon {
    
        public static void main(String[] args) {
            new PaintIcon();
        }
    
        public PaintIcon() {
            EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    try {
                        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
                    }
    
                    JFrame frame = new JFrame();
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame.setLayout(new BorderLayout());
                    frame.add(new PaintPane());
                    frame.pack();
                    frame.setLocationRelativeTo(null);
                    frame.setVisible(true);
                }
            });
        }
    
        public class PaintPane extends JPanel {
    
            private JLabel label;
            private int state = 0;
    
            private BufferedImage disk;
            private BufferedImage play;
            private BufferedImage pause;
            private BufferedImage stop;
    
            public PaintPane() {
    
                setLayout(new GridBagLayout());
                add((label = new JLabel()));
    
                try {
                    disk = ImageIO.read(getClass().getResource("/cd.png"));
                    play = ImageIO.read(getClass().getResource("/media_play.png"));
                    pause = ImageIO.read(getClass().getResource("/media_pause.png"));
                    stop = ImageIO.read(getClass().getResource("/media_stop.png"));
                } catch (Exception e) {
                    e.printStackTrace();
                }
    
                updateState();
    
                label.addMouseListener(new MouseAdapter() {
                    @Override
                    public void mouseClicked(MouseEvent e) {
                        state++;
                        if (state > 2) {
                            state = 0;
                        }
                        updateState();
                    }
                });
            }
    
            protected void updateState() {
                BufferedImage base = new BufferedImage(disk.getWidth(), disk.getHeight(), BufferedImage.TYPE_INT_ARGB);
                Graphics2D g2d = base.createGraphics();
                g2d.drawImage(disk, 0, 0, this);
                BufferedImage marker = null;
                switch (state) {
                    case 0:
                        marker = stop;
                        break;
                    case 1:
                        marker = play;
                        break;
                    case 2:
                        marker = pause;
                        break;
                }
                int x = disk.getWidth() - marker.getWidth();
                int y = disk.getHeight() - marker.getHeight();
                g2d.drawImage(marker, x, y, this);
                g2d.dispose();
    
                label.setIcon(new ImageIcon(base));
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created Java Swing application that i have exporter to runnable jar file.
I have a Java Swing application that is being used as a cluster application.
I have a Java swing application with a button that produces a popup window
So I have a strange problem, I have a java swing application that has
I've creating a Java Swing application and I realized that I have many many
I have a simple Swing Java application that performs searches, and the results are
We have a client side application (Java/Swing) that we need an HTML rendering control
I have a Java Swing application client that I want to use to consume
I have created one java-swing application. The application runs perfectly runs perfect on my
I have implemented an Java Swing application that uses an embedded JavaDB database. The

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.