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.
Calling
setIconwould overwrite the icon. However, you could try something like this: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.