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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:32:53+00:00 2026-06-15T12:32:53+00:00

I have made a JLabel where I display my images like this: BufferedImage myimage;

  • 0

I have made a JLabel where I display my images like this:

BufferedImage myimage;
imageLabel.setIcon(new ImageIcon(myimage));

Is it possible to draw an image and draw upon it a smaller image (an icon) with the setIcon command? How can I do it?

For example:

BufferedImage myimage1;
BufferedImage myLittleIcon;
imageLabel.setIcon(new ImageIcon(myimage1));
imageLabel.setIcon(new ImageIcon(myLittleIcon));

The above just draws the small icon.

  • 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-15T12:32:54+00:00Added an answer on June 15, 2026 at 12:32 pm

    Calling setIcon would overwrite the icon. However, you could try something like this:

    // Assumed that these are non-null
    BufferedImage bigIcon, smallIcon;
    
    // Create a new image.
    BufferedImage finalIcon = new BufferedImage(
        bigIcon.getWidth(), bigIcon.getHeight(),
        BufferedImage.TYPE_INT_ARGB)); // start transparent
    
    // Get the graphics object. This is like the canvas you draw on.
    Graphics g = finalIcon.getGraphics();
    
    // Now we draw the images.
    g.drawImage(bigIcon, 0, 0, null); // start at (0, 0)
    g.drawImage(smallIcon, 10, 10, null); // start at (10, 10)
    
    // Once we're done drawing on the Graphics object, we should
    // call dispose() on it to free up memory.
    g.dispose();
    
    // Finally, convert to ImageIcon and apply.
    imageLabel.setIcon(new ImageIcon(finalIcon));
    

    This creates a new image, paints the big icon, and then paints the small icon.

    You can also paint other things, like outlining a rectangle or filling an oval.

    For more advanced graphics functions, try casting to a Graphics2D object.

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

Sidebar

Related Questions

I have made a sql database using sql server. This database include images. When
I have made an application for IPad in objective C. In this I am
I have made an iphone application like flip cards in which values of cards
I have made a application for high resolution images. when I want to allocate
I have made a pretty little UI on storyboard but I'm quite new to
Im working in Java Swing using JWindows to display images... Ive made different JLabels
I have made a small swing application for my personal use. This app connects
I have made a Highcharts chart with grouped and stacked columns, like in the
I've made a custom subclass of JLabel . I have a single instance of
I have made this game for Mac OS, but I realised that i need

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.