De maneira alguma voc� est� sendo chato, est� ajudando bastante. Ali�s
obrigado mesmo!


Entendi o que voc� disse � respeito do super.paint. Fiz o c�digo com AWT e
deu certo. Por�m com Swing (o que estou utilizando n�o funciona).


Ent�o eu entend� o que estava me confundindo a cabe�a.


Estou fazendo a exten��o de JApplet, utilizando Swing, e no modelo do Swing,
o JApplet possui uns tr�s panes (getContentPane(), e outros dois, que n�o me
lembro).


Ao associonar o super.paint, o Pane provavelmente � atualizado. (update)


Por isto cheguei naquela solu��o. quando chamo paintComponents, o fundo
tamb�m � atualizado.
Seria bastante interessante uma maneira mais inteligente, como a poss�vel em
AWT.

J� tentei acionar o this.getContentPane().getGraphics().drawImage() para ver
se funcionava e n�o deu certo.


Depois de algumas tentativas cheguei no c�digo abaixo:


[]s




import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;

public class ApTeste extends JApplet {
  boolean isStandalone = false;

  Image imagemFundo = null;
  JToggleButton jToggleButton1 = new JToggleButton();
  JLabel jLabel1 = new JLabel();
  JTextPane jTextPane1 = new JTextPane();

 //Get a parameter value
  public String getParameter(String key, String def) {
    return isStandalone ? System.getProperty(key, def) :
      (getParameter(key) != null ? getParameter(key) : def);
  }

  //Construct the applet
  public ApTeste() {
  }

  public void paint(Graphics g)
  {

    /* A primeira tentativo foi :

    this.drawImage(imagemFundo,0,0,this);
    super.paint(g); // Funcionava em AWT
    */

    this.getContentPane().getGraphics().drawImage(imagemFundo,0,0,this);
    this.getContentPane().paint(this.getContentPane().getGraphics());
  }

  //Initialize the applet
  public void init() {
    try {
      imagemFundo =
Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("figura.gif
"));

      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }

  //Component initialization
  private void jbInit() throws Exception {
    jToggleButton1.setText("jToggleButton1");
    jToggleButton1.setBounds(new Rectangle(72, 65, 123, 79));
    this.getContentPane().setLayout(null);
    jLabel1.setText("jLabel1");
    jLabel1.setBounds(new Rectangle(104, 181, 98, 23));
    jTextPane1.setText("jTextPane1");
    jTextPane1.setBounds(new Rectangle(145, 15, 156, 36));
    this.getContentPane().add(jToggleButton1, null);
    this.getContentPane().add(jLabel1, null);
    this.getContentPane().add(jTextPane1, null);
  }

  //Start the applet
  public void start() {
  }

  //Stop the applet
  public void stop() {
  }

  //Destroy the applet
  public void destroy() {
  }

  //Get Applet information
  public String getAppletInfo() {
    return "Applet Information";
  }

  //Get parameter info
  public String[][] getParameterInfo() {
    return null;
  }

  //Main method
  public static void main(String[] args) {
    ApTeste applet = new ApTeste();
    applet.isStandalone = true;
    Frame frame;
    frame = new Frame() {

      protected void processWindowEvent(WindowEvent e) {
        super.processWindowEvent(e);
        if (e.getID() == WindowEvent.WINDOW_CLOSING) {
          System.exit(0);
        }
      }

      public synchronized void setTitle(String title) {
        super.setTitle(title);
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
      }
    };
    frame.setTitle("Applet Frame");
    frame.add(applet, BorderLayout.CENTER);
    applet.init();
    applet.start();
    frame.setSize(400,320);
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((d.width - frame.getSize().width) / 2, (d.height -
frame.getSize().height) / 2);
    frame.setVisible(true);
  }
}

    --------------------------- LISTA SOUJAVA ---------------------------
    http://www.soujava.org.br  -  Sociedade de Usu�rios Java da Sucesu-SP
    [d�vidas mais comuns: http://www.soujava.org.br/faq.htm]
    [para sair da lista: http://www.soujava.org.br/forum/cadastrados.htm]
    [regras da lista: http://www.soujava.org.br/regras.htm]
    ---------------------------------------------------------------------

Responder a