Quadro de imagem usando applet

2 respostas
S

Sou iniciante!

Como faço para exibir um quadro de imagem usando applet?

Consigo exibir uma, mas preciso exibir várias, um album de fotos.

2 Respostas

S
import java.awt.<em>;

import java.awt.Graphics;

import <a href="http://java.net">java.net</a>.</em>;

import java.util.Date;

public class Banner extends java.applet.Applet implements Runnable {

Image figuras;
Image atual;
    
Thread runner;
    String a, g ,h ,i ,j, k, l;
    String line;
    int m;
    TextField b1,b2;
    TextArea t;
    Label l1, l2, l3;
    Frame janela;

public void init() {

add(new Button(“Fechar janela”));

l1 = new Label(); 


a = getParameter("arquivo1");   


figuras = getImage(getCodeBase(), a);

g = getParameter("texto1");
}

public void start() {

if (runner == null) {

runner = new Thread(this);

runner.start();

}

}
public  void stop() {

if (runner != null) {

runner.stop();

runner = null;

}

}

public boolean action(Event evt, Object arg)  {

if (evt.target instanceof Button) {

String label = (String)arg;

if (label.equals(Fechar janela)) {

if (janela.isShowing())

janela.hide();

}

}

return true;

} // metodo action

public void run() {

setBackground(Color.white);

janela.add(b1);

b1.setText(test);
try {
    atualURL = new URL(g);
    }
catch (MalformedURLException e) {}

}

public boolean mouseDown(Event evt, int x,int y)
{

janela = new Frame("MEMBROS DO PROJETO");


janela.resize(500,450);
janela.setLayout(new FlowLayout());

janela.add(new Button("Fechar Janela"));    
janela.add(l1);    

l1.setText(g);
l1.setFont(new Font("Serif", Font.BOLD, 18));

janela.show();

return true;

}

public void paint(Graphics g) {

g.drawImage(figuras, 0, 0, this);

g.drawImage(figuras, 0, 0, this);

}

}

Este é o código que estou utilizando para exibir uma figura e a um click serão exibidos informações sobre a figura.

Como faço para exibi-las uma ao lado da outra ou em um quadro?

Rafael_Steil

Use JPanel e JFrame. Nao eh complicado de usar, mas tmb nao da pra explicar o funcionamento todo no forum. De uma lida nessa url:

http://java.sun.com/docs/books/tutorial/uiswing/mini/index.html

[]'s
Rafael Steil

Criado 26 de outubro de 2002
Ultima resposta 26 de out. de 2002
Respostas 2
Participantes 2