Basically, I am extracting images from a video in realtime as BufferedImages and displaying them within a JFrame after processing. Unfortunately I am very bad with swing, so while the images show up within the JFrame as intended, it spawns a new JFrame for every new image (24 per second).
I send the BufferedImages to the GUI with:
UserInterface.main(currentFrame);
Where they are received by my GUI class, which is essentially A JLabel containing the current image inside a JPanel inside a JFrame:
public class UserInterface extends JFrame {
private JPanel contentPane;
public static void main(BufferedImage inputImage) throws IOException
{
UserInterface frame = new UserInterface(inputImage);
frame.setVisible(true);
}
public UserInterface(BufferedImage inputImage) throws IOException
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(50, 50, 1024, 768);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel imageLabel = new JLabel(new ImageIcon(inputImage));
add(imageLabel);
imageLabel.setBounds(11, 60, 480, 360);
contentPane.add(imageLabel);
}
Can anyone advise on how to break this up to make just 1 JFrame appear, in which I can display all the images dynamically?