Por que não carrega!

4 respostas
Diego_Fontenele

Galera já achei alguns topicos sobre isso, tentei fazer do jeito que eles falaram mas mesmo assim não deu certo.
É o seguinte não consigo carregar imagem na minha janela queria que vcs dessem uma olhada para ver o que eu estou errando vlwww!

package temperatura;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

/**
 *
 * @author Diego
 */
public class BorderDemo2 extends JFrame {

    private JButton bAbrir, bSalvar, bFechar;
    private JTextArea taEditor;
    private JLabel jLabel1 ;

    public BorderDemo2(){
        super("BorderDemo2");
        setSize(300,200);
        setBackground(SystemColor.control);
        setLocation(300,300);
        Container cp=getContentPane();
     //painel topo

        JPanel p1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
        
        for(int i=0; i<3; i++){
        
         p1.add(new JLabel(new ImageIcon("link1.gif")));
         
            
        }
     //painel lateral
        p1 = new JPanel();
        JPanel p2 = new JPanel(new GridLayout(3, 1, 5, 5));
        p2.add(bAbrir = new JButton("Abrir"));
        p2.add(bSalvar = new JButton("Salvar"));
        p2.add(bFechar = new JButton("Fechar"));
        p1.add(p2);
        cp.add("East",p1);
     //componente central
        cp.add(new JScrollPane(taEditor=new JTextArea()),"Center");//colocando rolagem no textarea

     //listener
        bFechar.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                bFecharClick();
            }
        });

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
        private void bFecharClick(){
        System.exit(0);
        }

}

4 Respostas

janjan

cara blz

depois que vc seta o defaltCloseOperation

faz um

this.setVisible(true);

se é isso que vc quer!!!

Diego_Fontenele

Vlw pela atenção é o seguinte a janela aparece e os botoes tb só não aperece o icone!!!

janjan

jingle

voce deve por um action no teu botão de abrir, e neste action você pode usar um JFileChooser para escolher a imagem e por fim use a imagem escolhida para criar um imageIcon e por em um label.

Criado 19 de março de 2009
Ultima resposta 19 de mar. de 2009
Respostas 4
Participantes 3