I have a JPanel to which I’d like to add JPEG and PNG images that I generate on the fly. All the examples I’ve seen so far in the...
  • May 11, 2022
  • 0 Comments
Here’s how I do it (with a little more info on how to load an image): import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; import...
  • April 4, 2022
  • 0 Comments
JPanel doesn’t have ActionListener capabilities. Instead, you need to use a MouseListener import java.awt.Color; import java.awt.Container; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.GridLayout; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JFrame; import javax.swing.JPanel; public class CoordBoutons...
  • April 4, 2022
  • 0 Comments