ahh, esqueci de dizer, a string teste aparece na janela, e se eu por
fillrect ( por exemplo) ele tambem aparece, mas qualquer coisa que que
seja com drawimagem, drawoval, nada disso funciona...

On Jun 6, 12:37 pm, Luan <[email protected]> wrote:
> Alguem pode me ajudar, to tentando por uma imagem para aparecer no
> fundo da tela, mas ela n aparece em lugar nenhum, segue o codigo:
>
> package adm;
>
> import java.awt.Color;
> import java.awt.Graphics;
> import java.awt.Image;
> import java.awt.MediaTracker;
> import java.awt.Toolkit;
> import java.io.File;
> import java.io.IOException;
>
> import javax.imageio.ImageIO;
> import javax.swing.JButton;
> import javax.swing.JFrame;
> import javax.swing.JOptionPane;
> import javax.swing.JPanel;
> import javax.swing.JScrollBar;
> import javax.swing.JScrollPane;
>
> public class Caracteristicas_Comprador extends JFrame{
>
>         JFrame janela = new JFrame("Janela teste");
>         JPanel painel = new JPanel();
>         JScrollPane scroll = new JScrollPane(painel);
>         Graphics graphs;
>         String string = "Teste!";
>         Image imagem;
>
>         public Caracteristicas_Comprador() {
>
>                         this.montajanela();
>                         this.escreve();
>                         this.carregaImagem();
>         }
>
>         private void montajanela() {
>
>                 janela.add(scroll);
>                 janela.setSize(800,640);
>                 janela.setVisible(true);
>                 janela.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>
>                 graphs = painel.getGraphics();
>         }
>
>         private void escreve() {
>
>                 while(true){
>                         graphs.setColor(new Color (0,0,0));
>                         graphs.drawString(string, janela.getWidth()/2, 
> janela.getHeight()/
> 2);
>                 }
>         }
>
>         private void carregaImagem() {
>
>                 imagem = Toolkit.getDefaultToolkit().getImage("C:\\Documents 
> and
> Settings\\Luan\\Meus documentos\\Minhas imagens\\Com alguem\\Chuchu e
> eu\\eu i luan1.jpeg");
>                 MediaTracker mt = new MediaTracker(this);
>                 mt.addImage(imagem, 1);
>                 try {
>                                 mt.waitForAll();
>                 } catch (InterruptedException e) {
>                             e.printStackTrace();
>                 }
>                 graphs.drawImage(imagem, 50, 50, this);
>                 }
>
> }
>
> OBS: não tme erro de compilação n!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Comp 
2 - Geral" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/comp2-geral?hl=en
-~----------~----~----~----~------~----~------~--~---

Responder a