Como inserir imagens num programa em java

4 respostas
B

Como q eu faço pra exibir uma imagem (normal, jpg, jpeg, etc, salva no meu computador, no diretorio do programa) num programa???

4 Respostas

CintiaDR

O que vc quer dizer com ‘exibir’?

Programa com interface gráfica?

ViniGodoy

Você pode usar esse painel:
http://www.guj.com.br/posts/list/56248.java#295271

lgi2020

Tente usar um JLabel.

Abraços.

lgi2020

Exemplo do JLabel com um Icon

// Fetch icon
    Icon icon = new ImageIcon("icon.gif");
    
    // Create a label with text and an icon; the icon appears to the left of the text
    JLabel label = new JLabel("Text Label", icon, JLabel.CENTER);
    
    // Create a label with only an icon
    label = new JLabel(icon);

This example adds or replaces the icon in an existing JLabel component: 
    // Add an icon to an existing label
    label.setIcon(icon);
Criado 4 de dezembro de 2007
Ultima resposta 5 de dez. de 2007
Respostas 4
Participantes 4