View an image with Java Swing Jlabel

Asked

Viewed 1,508 times

1

I’m trying to display an image in an app using Swing Java. I take some frames from a video and display them as an image

    private void updateView(){
    Image tempCurrent = imageProcessor.toBufferedImage(currentImage);
    currentImageView.setIcon(new ImageIcon(tempCurrent));

    //JOptionPane.showMessageDialog(null, "um alo");

}

O Jlabel video é a o currentImageView. O container de fora é um JPanel

I am not a Java programmer, but I need to maintain this code. The "currentImageView.setIcon" procedure should display an image in the Jpanel, but simply does nothing. The variable currentImaveView is Jlabel video. The funny part is that if I run the "Joptionpane", ah image appears.

Can someone help me?

  • What is currentImageView? Where is this component?

  • 1

    You can post more parts of the code?

  • currentImageView is a Jlabel

  • The print is pointing to an invalid link.

  • It must be because I edited the image, but now it’s normal.

  • If the image appears when Joptionpane appears, then it may be a matter of calling "repaint()". Try this: Run without making Joptionpane appear, then minimize the Window and maximize it (this will cause a repaint), or resize it (it should cause multiple repaints).

Show 1 more comment

1 answer

1

Use this code if you want to put an image inside the jlabel:

// Import ImageIcon     
ImageIcon iconLogo = new ImageIcon("Images/YourCompanyLogo.png");

"nome da variable da jlabel".setIcon(iconLogo);
  • did you read the question? He already did so, the problem was not that..

Browser other questions tagged

You are not signed in. Login or sign up in order to post.