Ir para conteúdo
Fórum Script Brasil
  • 0

Troca De Parâmetro Applet Dinâmico


diego_mota

Pergunta

oi caros colegas

Tenho um Java Applet (fonte do sistema: http://www.thejmaker.com/SlidingPuzzle.html) que faz um joguinho de quebracabeça com uma foto que você fornece como parâmetro, conforme trecho do código abaixo:

<param name=photo value="images/praia.jpg">

O meu problema é que gostaria de alterar as fotos toda vez que alguém escolhesse uma foto em um menu "select". Como eu poderia alterar esse parâmetro usando uma caixa select e javascript?

O que tentei: Já tentei usar javascript para atualizar o applet inserido em tag div para incluir o applet, mas daí funciona parcialmente: no mozilla/netscape não faz a troca, no ie 5.0 funciona normalmente e no ie 6.0 funciona mas com travamento quando o applet embaralha as peças. É necessário então instalar o J2RE para que funcione no Ie6, o que'torna inviável pedir para que cada internauta faça. Mas, como já vi que nào dá muito certo por esses meios, gostaria de tentar alterar sem usar tag <div>

Link para o comentário
Compartilhar em outros sites

Posts Recomendados

  • 0

tenta usar o método getElementsByTagName(name).

<html>
<head>
<script language="javascript">
function troca(name, value) {
    document.getElementsByTagName(name).value = value
}
</script>
</head>
<body>
<form name="frm">
<input type="text" name="nome" onBlur="tel(this)">
<select name="select" onchange="troca('photo', this.options[this.selectedIndex].text)">
<option value="1">Foto1</option>
<option value="2">Foto2</option>
<option value="3">Foto3</option>
<option value="4">Foto4</option>
</select>
<param name="photo" value="images/praia.jpg">
</form>
</body>
</html>

Já utilizei applets mas faz tempo não estou muito lembrado por isso não coloquei o código completo do applet.

Não sei se te ajudei, qualquer coisa posta ae.

Abraço

Crystian

Link para o comentário
Compartilhar em outros sites

  • 0

Bom amigo, não deu certo a dica que você deu.

Ele parece que faz a troca da tag (coloquei um alert para verificar) mas não muda no applet. Talvez seja necessário reinicializar o applet..não sei (até tentei acionar via javascript a função construtora q faz isso dentro do arquivo .class, mas o applet trava..).

Dê uma olhada no código no seguinte endereço:

http://dhost.info/rebenta/gatas/quebracabeca.htm

Abaixo vai o código do .class principal do applet:

// Decompiled by DJ v3.7.7.81 Copyright 2004 Atanas Neshkov  Date: 27/09/2004 13:39:06
// Source File Name:   SlidingPuzzle.java

import java.applet.*;
import java.awt.*;
import java.net.URL;
import java.util.Date;
import java.util.StringTokenizer;

public class SlidingPuzzle extends Applet
    implements Runnable
{

    public SlidingPuzzle()
    {
        t = null;
        delay = 200;
        row = 4;
        col = 4;
        scramblestart = 0;
        registered = false;
        gameover = false;
        linkto = "";
        linkframe = "";
        RowText = "Row:";
        ColText = "Col:";
    }

    public void init()
    {
        super.init();
        width = size().width;
        height = size().height;
        String s = getParameter("regcode");
        s.trim();
        s.toUpperCase();
        int i = s.charAt(0) - 48;
        if(i > 9)
            i -= 7;
        int j = s.charAt(s.length() - 1) - 48;
        int k = 0xf423f;
        if(i + 3 < s.length())
        {
            int l = (new Integer(s.substring(i, i + 3))).intValue();
            if(l == 988 && j == (i * 988) % 10)
                registered = true;
        }
        if(!registered)
        {
            int j1 = j;
            j = i;
            i = j1;
            if(i + 4 < s.length())
            {
                int i1 = (new Integer(s.substring(i, i + 4))).intValue();
                if(i1 == 1027 && j == (i + 1027) % 10)
                    registered = true;
            }
        }
        delay = (new Integer(getParameter("delay"))).intValue();
        picfile = getParameter("photo");
        scramblestart = (new Integer(getParameter("scramblestart"))).intValue();
        int k1 = (new Integer(getParameter("frames"))).intValue();
        winfile = getParameter("winfile");
        movefile = getParameter("movefile");
        int ai[] = parseInt(getParameter("panelbg"));
        bg = new Color(ai[0], ai[1], ai[2]);
        ai = parseInt(getParameter("panelfg"));
        fg = new Color(ai[0], ai[1], ai[2]);
        ai = parseInt(getParameter("buttonbg"));
        butbg = new Color(ai[0], ai[1], ai[2]);
        ai = parseInt(getParameter("buttonfg"));
        butfg = new Color(ai[0], ai[1], ai[2]);
        String as[] = parse(getParameter("linkto").trim());
        linkto = as[0];
        linkframe = as[1];
        row = (new Integer(getParameter("row"))).intValue();
        col = (new Integer(getParameter("col"))).intValue();
        TitleText = getParameter("TitleText");
        NewGameText = getParameter("NewGameText");
        SolvePuzzleText = getParameter("SolvePuzzleText");
        MovesCountText = getParameter("MovesCountText");
        BestText = getParameter("BestText");
        FinishText = getParameter("FinishText");
        winaudio = getAudioClip(getDocumentBase(), winfile);
        moveaudio = getAudioClip(getDocumentBase(), movefile);
        readPhoto(picfile);
        rp = new SlidingPuzzlePhoto(photo, picwidth, picheight, row, col, this);
        rp.maxtransit = k1;
        rp.delay = delay;
        rp.registered = registered;
        rp.bg = bg;
        rp.winaudio = winaudio;
        rp.moveaudio = moveaudio;
        rp.gameover = gameover;
        rp.MovesCountText = MovesCountText;
        rp.FinishText = FinishText;
        rp.BestText = BestText;
        rp.repaint();
        Panel panel = new Panel(new BorderLayout());
        panel.add("Center", rp);
        setBackground(bg);
        setForeground(fg);
        GridBagLayout gridbaglayout = new GridBagLayout();
        GridBagConstraints gridbagconstraints = new GridBagConstraints();
        gridbagconstraints.fill = 0;
        gridbagconstraints.gridwidth = 0;
        gridbagconstraints.anchor = 10;
        Panel apanel[] = new Panel[5];
        for(int l1 = 0; l1 < 5; l1++)
            apanel[l1] = new Panel();

        buttonNew = new SlidingPuzzleButton(80, 20, NewGameText, "Helvetica", 11, butbg, butfg);
        buttonNew.setBGmain(bg);
        apanel[0].add(buttonNew);
        buttonSolve = new SlidingPuzzleButton(80, 20, SolvePuzzleText, "Helvetica", 11, butbg, butfg);
        buttonSolve.setBGmain(bg);
        apanel[1].add(buttonSolve);
        Panel panel1 = new Panel();
        panel1.setLayout(new FlowLayout());
        for(int i2 = 0; i2 < 2; i2++)
            panel1.add(apanel[i2]);

        panel.add("South", panel1);
        Label label = new Label(TitleText, 1);
        label.setBackground(bg);
        label.setForeground(fg);
        label.setFont(new Font("Helvetica", 1, 20));
        panel.add("North", label);
        add(panel);
        resize(width, height);
        show();
        repaint();
    }

    public void start()
    {
        if(t == null)
        {
            t = new Thread(this);
            t.start();
        }
    }

    public void stop()
    {
        if(t != null && t.isAlive())
            t.stop();
        t = null;
        photo = null;
        rp = null;
    }

    public void run()
    {
        System.gc();
        int i = 0;
        if(scramblestart > 0)
        {
            rp.rescramble();
            rp.repaint();
        }
        while(Thread.currentThread() == t) 
        {
            if(i++ > 1000)
            {
                i = 0;
                System.gc();
            }
            try
            {
                Thread.sleep(500L);
            }
            catch(InterruptedException interruptedexception) { }
            rp.repaint();
            if(rp.gameover && !linkto.equalsIgnoreCase("none"))
            {
                try
                {
                    URL url = new URL(getDocumentBase(), linkto);
                    getAppletContext().showDocument(url, linkframe);
                }
                catch(Exception exception)
                {
                    exception.printStackTrace();
                }
                rp.gameover = false;
            }
            if(!registered)
            {
                Date date = new Date();
                if(date.getMinutes() % 5 == 0 && date.getSeconds() < 2)
                    try
                    {
                        URL url1 = new URL(getDocumentBase(), "http://www.thejmaker.com/");
                        getAppletContext().showDocument(url1);
                    }
                    catch(Exception exception1)
                    {
                        exception1.printStackTrace();
                    }
                date = null;
            }
        }
    }

    public void readPhoto(String s)
    {
        showStatus("Reading image " + s);
        photo = null;
        photo = getImage(getDocumentBase(), s);
        for(picwidth = picheight = -1; picwidth < 0 || picheight < 0;)
        {
            picwidth = photo.getWidth(this);
            picheight = photo.getHeight(this);
            try
            {
                Thread.sleep(20L);
            }
            catch(Exception exception) { }
        }

        showStatus("Photo " + s + " (" + picwidth + "x" + picheight + ") ready");
    }

    int[] parseInt(String s)
    {
        StringTokenizer stringtokenizer = new StringTokenizer(s, " ");
        int ai[] = new int[stringtokenizer.countTokens()];
        for(int i = 0; i < ai.length; i++)
            ai[i] = Integer.parseInt(stringtokenizer.nextToken());

        return ai;
    }

    String[] parse(String s)
    {
        StringTokenizer stringtokenizer = new StringTokenizer(s, "|");
        String as[] = new String[stringtokenizer.countTokens()];
        for(int i = 0; i < as.length; i++)
            as[i] = stringtokenizer.nextToken();

        return as;
    }

    public void update(Graphics g)
    {
        paint(g);
    }

    public void paint(Graphics g)
    {
        g.setColor(bg);
        g.draw3DRect(0, 0, width - 1, height - 1, true);
        g.draw3DRect(1, 1, width - 3, height - 3, true);
    }

    public Insets insets()
    {
        return new Insets(0, 0, 0, 0);
    }

    public Dimension minimizeSize()
    {
        return new Dimension(width, height);
    }

    public Dimension preferredSize()
    {
        return new Dimension(width, height);
    }

    public boolean action(Event event, Object obj)
    {
        if(event.target == buttonNew)
        {
            rp.target = -1;
            rp.makePieces(row, col);
            rp.moves = 0;
            rp.gameover = false;
            rp.rescramble();
            rp.repaint();
            return true;
        }
        if(event.target == buttonSolve)
        {
            rp.target = -1;
            rp.resetPositions();
            rp.moves = 0;
            rp.gameover = false;
            rp.repaint();
            return true;
        } else
        {
            return false;
        }
    }

    Image photo;
    Thread t;
    int width;
    int height;
    int delay;
    String picfile;
    int picwidth;
    int picheight;
    Color bg;
    Color fg;
    Color butbg;
    Color butfg;
    int row;
    int col;
    int scramblestart;
    SlidingPuzzleButton buttonNew;
    SlidingPuzzleButton buttonSolve;
    SlidingPuzzlePhoto rp;
    AudioClip winaudio;
    AudioClip moveaudio;
    String winfile;
    String movefile;
    boolean registered;
    boolean gameover;
    String linkto;
    String linkframe;
    String TitleText;
    String NewGameText;
    String SolvePuzzleText;
    String RowText;
    String ColText;
    String MovesCountText;
    String FinishText;
    String BestText;
}

Link para o comentário
Compartilhar em outros sites

  • 0

primeira coisa, troca uma linha de código que acabei te passando equivocadamente.

Essa: [COLOR=red]<select name="select" onchange="troca('photo', this.options[this.selectedIndex].text)">[/COLOR=red]
Por: [COLOR=blue]<select name="select" onchange="troca('photo', this.options[this.selectedIndex].value)">[/COLOR=blue]

Com essa troca você não precisa "mostrar" o caminha da imagem no select (combo), pode colocar somente o caminho no value.

Eu tenho que pegar o teu código e dar uma olhada, vou fazer isso e depois te respondo.

Abraço

Crystian

Link para o comentário
Compartilhar em outros sites

  • 0

Andei me informando sobre o objeto applet e descobri que os "<param>" dentro dele não podem ser modificados, eles somente são carregados quando se carrega a página.

Pensando assim, tenta submitar a página.

<html>
<head>
<script language="Javascript">
function mudaGata(id, value) {
   document.getElementById(id).value = value;
   document.frm.submit();
};
</script>
</head>
<body>
  <center>
  <table border="0" cellpadding="0" cellspacing="1" width="100%">
    <tr>
      <td width="50%">
        <p align="left"> Escolher gata:
  <form name="frm">
        	<input type="text" name="nome" onBlur="tel(this)">
            <select name="select" onChange="mudaGata('foto', this.options[this.selectedIndex].value);">
              <option value="images/_izoca.jpg" selected>images/_izoca.jpg</option>
              <option value="images/anazuca.jpg">images/anazuca.jpg</option>
              <option value="images/aninhabdl.jpg">images/aninhabdl.jpg</option>
              <option value="images/brunenhaa.jpg">images/brunenhaa.jpg</option>
              <option value="images/carolinabela.jpg">images/carolinabela.jpg</option>
              <option value="images/claufreak.jpg">images/claufreak.jpg</option>
              <option value="images/dessaribas.jpg">images/dessaribas.jpg</option>
              <option value="images/ellen.jpg">images/ellen.jpg</option>
              <option value="images/grazinha.jpg">images/grazinha.jpg</option>
              <option value="images/mozuda.jpg">images/mozuda.jpg</option>
              <option value="images/nathaliah.jpg">images/nathaliah.jpg</option>
              <option value="images/tezinhaa.jpg">images/tezinhaa.jpg</option>
              <option value="images/um_s_na_estrela.jpg">images/um_s_na_estrela.jpg</option>
              <option value="images/vanihhh.jpg">images/vanihhh.jpg</option>
            </select></p>
            <applet code="SlidingPuzzle.class" archive="SlidingPuzzle.jar" width="600" height="590">
                <param name=regcode value="99999999">
                <!-- number of frames in the animation of swapping pieces --><param name=frames value="30">
                <!-- animation delay between frames in milliseconds --><param name=delay value="20">
                <!-- photo file for the puzzle --><param id="foto" name="photo" value="images/_izoca.jpg">
                <!-- toggle to start with a scrambled mode (0 = no init scarmble) --><param name=scramblestart value="1">
                <!-- winning audio filename --><param name=winfile value="SlidingPuzzle1.au">
                <!-- moving audio filename --><param name=movefile value="SlidingPuzzle2.au">
                <!-- panel background color: R G B --><param name=panelbg value="143 31 192">
                <!-- panel foreground color: R G B --><param name=panelfg value="255 199 0">
                <!-- button background color: R G B --><param name=buttonbg value="255 199 0">
                <!-- button foreground color: R G B --><param name=buttonfg value="0 0 0">
                <!-- "|" seperates gameover URL and target frame -->
                <!-- fill in "none" for URL if  you don"t want any URL -->
                <!-- target frame options are as follows -->
                <!-- _self   = current frame -->
                <!--_parent = parent frame -->
                <!--       _top    = top-most frame -->
                <!--       _blank  = new unnamed top-level frame -->
                <!--       x       = new top-level frame named x -->
                <param name=linkto value="none|_self">
                <!-- number of rows and columns to divide the puzzle -->
                <!-- Note. Please make sure puzzle width and height are divisible by row and col.-->
                <param name=row value="4"><param name=col value="5">
                <!-- all text strings --><param name=TitleText value="Quebra Cabe&ccedil;a de Gatas">
                <param name=NewGameText value="Misturar">
                <param name=SolvePuzzleText value="Resolver">
                <param name=MovesCountText  value="Contador:">
                <param name=BestText value="O melhor desempenho:">
                <param name=FinishText value="Voc&ecirc; conseguiu montar uma gata!">
            </applet><!------COPY AND PASTE THE CODE ABOVE THIS LINE----------------------------->
      </form></td>
      <td width="50%">
    </td>
    </tr>
  </table>
  </center>
</body>
</html>

esse é o código, vê se funciona e depois me avisa,

abraço

Crystian

Link para o comentário
Compartilhar em outros sites

  • 0

é! realmente tah complicado, mas não vamo desisti. Tenta tirar aquele submit, e recarregar o applet.

Dei uma olhada e para recarregar o applet, tu pode fazer o seguinte:

Coloca um id no applet : id="applet"

Depois pára o applet: document.getElementById("applet").stop();

Depois inicia o applet: document.getElementById("applet").start();

Esses códigos vão no lugar da linha que contem o submit() daquela função.

Troca lá e vê se dá certo, se não der me avisa, que vamo dar um jeito.

Abraço

Crystian

Link para o comentário
Compartilhar em outros sites

  • 0

Desculpa... me esqueci de te dizer uma coisa...

Você precisa criar o método stop() e start() na tua classe java.

Vou te mandar um exemplo que eu fiz, dá uma olhada e depois adapta pra tua classe java.

<HTML>
<HEAD>
<TITLE>Exemplo pro Diego</TITLE>
<script LANGUAGE="JavaScript1.1">

function setTimeZone(popup) {
	var choice = popup.options[popup.selectedIndex].value
	document.clock2.setTimeZone(choice)
}

function setColor(form) {
	var bg = form.backgroundColor.options[form.backgroundColor.selectedIndex].value
	var fg = form.foregroundColor.options[form.foregroundColor.selectedIndex].value
	document.clock2.setColor(bg, fg)
}

function setFont(form) {
	var fontName = form.theFont.options[form.theFont.selectedIndex].value
	var fontStyle = form.theStyle.options[form.theStyle.selectedIndex].value
	var fontSize = form.theSize.options[form.theSize.selectedIndex].value
	document.clock2.setFont(fontName, fontStyle, fontSize)
}
function getAppletInfo(form) {
	form.details.value = document.clock2.getInfo()
}

function showSource() {
	var newWindow = window.open("ScriptableClock.java","", "WIDTH=450,HEIGHT=300,RESIZABLE,SCROLLBARS")
}

</SCRIPT>
</HEAD>
<BODY>
<APPLET CODE="ScriptableClock.class" NAME="clock2" WIDTH=500 HEIGHT=45>
<PARAM NAME=bgColor VALUE="Black">
<PARAM NAME=fgColor VALUE="Red">
</APPLET>

<P>
<FORM NAME="widgets2">
Selecione Time Zone:
<SELECT NAME="zone" onChange="setTimeZone(this)">
	<OPTION SELECTED VALUE="Locale">Local Time
	<OPTION VALUE="GMT">Greenwich Mean Time
</SELECT><P>
Selecione Background Color:
<SELECT NAME="backgroundColor" onChange="setColor(this.form)">
	<OPTION VALUE="White">Branco
	<OPTION SELECTED VALUE="Black">Preto
	<OPTION VALUE="Red">Vermelho
	<OPTION VALUE="Green">Verde
	<OPTION VALUE="Blue">Azul
	<OPTION VALUE="Yellow">Amarelo
</SELECT>
Selecione a cor do texto:
<SELECT NAME="foregroundColor" onChange="setColor(this.form)">
	<OPTION VALUE="White">Branco
	<OPTION VALUE="Black">Preto
	<OPTION SELECTED VALUE="Red">Vermelho
	<OPTION VALUE="Green">Verde
	<OPTION VALUE="Blue">Azul
	<OPTION VALUE="Yellow">Amarelo
</SELECT><P>
Selecione a fonte:
<SELECT NAME="theFont" onChange="setFont(this.form)">
	<OPTION SELECTED VALUE="TimesRoman">Times Roman
	<OPTION VALUE="Helvetica">Helvetica
	<OPTION VALUE="Courier">Courier
	<OPTION VALUE="Arial">Arial
</SELECT><BR>
Selecione o estilo da fonte:
<SELECT NAME="theStyle" onChange="setFont(this.form)">
	<OPTION SELECTED VALUE="Plain">Plain
	<OPTION VALUE="Bold">Bold
	<OPTION VALUE="Italic">Italic
</SELECT><BR>
Selecione o tamanho da fonte:
<SELECT NAME="theSize" onChange="setFont(this.form)">
	<OPTION VALUE="12">12
	<OPTION VALUE="18">18
	<OPTION SELECTED VALUE="24">24
	<OPTION VALUE="30">30
</SELECT><P>
<HR>
<INPUT TYPE="button" NAME="getInfo" VALUE="Applet InfoÉ" onClick="getAppletInfo(this.form)">
<P>
<TEXTAREA NAME="details" ROWS=11 COLS=70></TEXTAREA>
</FORM>
<HR>
</BODY>
</HTML>
Esta é a página E esse é o código java:
import java.awt.*;
import java.util.Date;

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

	// controle das Variaveis
	final boolean GMT = true;
	final boolean LOCALE = false;
	String displayDate;
	Font displayFont;
	Thread thread;

	// Parametros opcionais
	Color bgColor;
	Color fgColor;
	Rectangle displayArea;
	String fontName;
	int fontSize;
	int fontStyle;
	int height, width;
	boolean timeZone;

	public void init() {
  parseArgs();
  displayFont = new Font(fontName, fontStyle, fontSize);
  timeZone = LOCALE;
  displayArea = bounds();
  height = displayArea.height;
  width = displayArea.width;
  resize(width,height);
	}

	public void start() {
  if(thread == null) {
  	thread = new Thread(this);
  	thread.start();
  }
	}

	public void stop() {
  if(thread != null) {
  	thread.stop();
  	thread = null;
  }
	}

	public void run() {
  while(thread != null) {
  	Date theDate = new Date();
  	displayDate = (timeZone) ? theDate.toGMTString() : theDate.toLocaleString();
  	repaint();
  	try {
    Thread.sleep(1000);
  	}
  	catch(InterruptedException e)  {}
  }
	}

	public void paint(Graphics g) {
  g.setColor(bgColor);
  g.fillRect(0,0,width,height);

  g.setColor(fgColor);
  g.setFont(displayFont);

  FontMetrics fm = getFontMetrics(getFont());
  int textWidth = fm.stringWidth(displayDate);
  int horizOffset = (width / 2) - (textWidth / 2);
  g.drawString(displayDate,5,35);
	}


	/*
    inicio dos metodos públicos para
          pegar e setar os dados via LiveConnect
	*/
	public void setTimeZone(String zone) {
  stop();
  timeZone = (zone.startsWith("GMT")) ? true : false;
  start();
	}

	public void setFont(String newFont, String newStyle, String newSize) {
  stop();
  if (newFont != null && newFont != "")
  	fontName = newFont;
  if (newStyle != null && newStyle != "")
  	setFontStyle(newStyle);
  if (newSize != null && newSize != "")
  	setFontSize(newSize);
  displayFont = new Font(fontName, fontStyle, fontSize);
  start();
	}

	public void setColor(String newbgColor, String newfgColor) {
  stop();
  bgColor = parseColor(newbgColor);
  fgColor = parseColor(newfgColor);
  start();
	}

	public String getInfo() {
  String result = "Info about ScriptableClock.class\r\n";
  result += "Version/Date: 1.0d1/2 May 1996\r\n";
  result += "Author: Danny Goodman (dannyg@dannyg.com)\r\n";
  result += "Public Variables:\r\n";
  result += "   (None)\r\n\r\n";
  result += "Public Methods:\r\n";
  result += "   setTimeZone(\"GMT\" | \"Locale\")\r\n";
  result += "   setFont(\"fontName\",\"Plain\" |\"Bold\" | \"Italic\", \"fontSize\")\r\n";
  result += "   setColor(\"bgColorName\", \"fgColorName\")\r\n";
  result += "       colors: Black, White, Red, Green, Blue, Yellow\r\n";
  return result;
	}
	/*
  Fim dos metodos publicos.
	*/


	private void setFontStyle(String style) {
  try {
  	if(style.equalsIgnoreCase("Plain"))
    fontStyle = Font.PLAIN;
  	else if(style.equalsIgnoreCase("Italic"))
    fontStyle = Font.ITALIC;
  	else
    fontStyle = Font.BOLD;
  }
  catch(Exception e) {
  	fontStyle = Font.BOLD;
  }
	}

	private void setFontSize(String size) {
  try {
  	fontSize = Integer.parseInt(size);
  }
  catch(Exception e) {
  	fontSize = 24;
  }
	}

	private void parseArgs() {
  fontName = getParameter("font");
  if (fontName == null) {
  	fontName = new String("TimesRoman");
  }

  String n = getParameter("fontSize");
  setFontSize(n);

  n = getParameter("fontStyle");
  setFontStyle(n);

  bgColor = parseColor(getParameter("bgColor"));
  if(bgColor == null)
  	bgColor = Color.white;

  fgColor = parseColor(getParameter("fgColor"));
  if(fgColor == null)
  	fgColor = Color.black;
	}

	private Color parseColor(String c) {
  try {
  	if (c.equalsIgnoreCase("Black"))
    return Color.black;
  	else if (c.equalsIgnoreCase("White"))
    return Color.white;
  	else if (c.equalsIgnoreCase("Red"))
    return Color.red;
  	else if (c.equalsIgnoreCase("Green"))
    return Color.green;
  	else if (c.equalsIgnoreCase("Blue"))
    return Color.blue;
  	else if (c.equalsIgnoreCase("Yellow"))
    return Color.yellow;
  	else
    return Color.black;
  }
  catch (Exception e) {
  	return null;
  }
	}
}

Dá uma olhada e depois me diz se era isso que você queria...

Abraço

Crystian

Link para o comentário
Compartilhar em outros sites

  • 0

Não deu certo tb. É..eu já havia tentado algumas funções do applet fora essas. Acho que daria certo se o objeto fosse destruído, criado um novo e carregado as funções iniciais para liberar a memória..só que não sei como induzir o javascript a executar estas ações, já que aparentemente ele terá que invocar várias funções para efetuar um "reset".

Para facilitar vou te passar um endereço para você pegar todos os arquivos zipados onde estou tentando trabalhar: http://dhost.info/rebenta/gatas/download.htm

Link para o comentário
Compartilhar em outros sites

  • 0

Já existem esses métodos na classe java: Dá uma olhada:

public void start()
   {
       if(t == null)
       {
           t = new Thread(this);
           t.start();
       }
   }

   public void stop()
   {
       if(t != null && t.isAlive())
           t.stop();
       t = null;
       photo = null;
       rp = null;
   }

Link para o comentário
Compartilhar em outros sites

  • 0

Tenta no começo da função fazer um stop, troca o nome da imagem e depois starta o applet de novo.

mais ou menos assim...

function mudaGata(id, value) {

document.getElementById("applet").stop();

document.getElementById(id).value = value;

document.getElementById("applet").start();

}

e declara o id no applet, se não não funciona mesmo, outra coisa tu tem que colocar um id no parametro q tem a url da foto, no nosso caso o param de nome "photo"... Coloca id="photo" e vê se tah passando certo os parâmetros no onchange.

Teteia de novo depois me avisa...

Abraço

Crystian

Link para o comentário
Compartilhar em outros sites

  • 0

Eu só não testei o de alterar o .class

Na verdade, eu já havia tentado fazer isso semana passada, mas não conseguia compilar de jeito nenhum...Daí desisti de ficar mexendo no código fonte do applet. Você pegou os arquivos que eu deixei para você fazer o download? Talvez você entenda melhor se vir todo o código.

É muito estranho que o stop e start não funcionem para atualizar o applet..os códigos são similares aos do exemplo que você me passou. Qual serão as funções que fazem isso..??

Link para o comentário
Compartilhar em outros sites

  • 0

ok Crystian

Abaixo segue o código dos outros dois arquivos java, que eu descompilei agora. Estou testando diversas funções, sem sucesso por enquanto.

SlidingPuzzleButton

// Decompiled by DJ v3.7.7.81 Copyright 2004 Atanas Neshkov  Date: 27/09/2004 17:43:31
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   SlidingPuzzle.java

import java.awt.*;

class SlidingPuzzleButton extends Canvas
{

    SlidingPuzzleButton(int i, int j, String s, String s1, int k, Color color, Color color1)
    {
        shadc = new Color(220, 220, 220);
        arc = 11;
        width = i;
        height = j;
        caption = s;
        fonttype = s1;
        fontsize = k;
        bg = color;
        bgmain = color;
        fg = color1;
        resize(i, j);
        status = 0;
        repaint();
    }

    public void setBGmain(Color color)
    {
        bgmain = color;
        repaint();
    }

    public void update(Graphics g)
    {
        paint(g);
    }

    public void paint(Graphics g)
    {
        g.setColor(bgmain);
        g.fillRect(0, 0, width - 1, height - 1);
        if(status == 1)
            g.setColor(Color.red);
        else
        if(status == 2)
            g.setColor(fg);
        else
            g.setColor(bg);
        g.fillRoundRect(0, 0, width - 2, height - 2, arc, arc);
        g.setFont(new Font(fonttype, 1, fontsize));
        int i = g.getFontMetrics().stringWidth(caption);
        int j = g.getFontMetrics().getHeight();
        int k = g.getFontMetrics().getDescent();
        textx = (width - i) / 2;
        texty = (height + j) / 2 - k - 1;
        g.setColor(shadc);
        g.drawRoundRect(1, 1, width - 2, height - 2, arc, arc);
        g.drawString(caption, textx + 1, texty + 1);
        if(status == 2)
            g.setColor(bg);
        else
            g.setColor(fg);
        g.drawString(caption, textx, texty);
        g.drawRoundRect(0, 0, width - 1, height - 1, arc, arc);
    }

    public boolean mouseExit(Event event, int i, int j)
    {
        status = 0;
        repaint();
        return true;
    }

    public boolean mouseEnter(Event event, int i, int j)
    {
        status = 1;
        repaint();
        return true;
    }

    public boolean mouseDown(Event event, int i, int j)
    {
        status = 2;
        repaint();
        return true;
    }

    public boolean mouseUp(Event event, int i, int j)
    {
        if(inside(i, j))
        {
            status = 1;
            repaint();
            if(!action(event, event.arg))
            {
                for(java.awt.Container container = getParent(); container != null && !container.action(event, event.arg); container = container.getParent());
            }
        }
        return true;
    }

    public Insets insets()
    {
        return new Insets(0, 0, 0, 0);
    }

    public Dimension getMinimizeSize()
    {
        return new Dimension(width, height);
    }

    public Dimension getPreferredSize()
    {
        return new Dimension(width, height);
    }

    int width;
    int height;
    int fontsize;
    Color bg;
    Color fg;
    Color bgmain;
    Color shadc;
    int arc;
    String caption;
    String fonttype;
    int status;
    int textx;
    int texty;
}
e SlidingPuzzlePhoto
// Decompiled by DJ v3.7.7.81 Copyright 2004 Atanas Neshkov  Date: 27/09/2004 17:44:02
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   SlidingPuzzle.java

import java.applet.Applet;
import java.applet.AudioClip;
import java.awt.*;
import java.awt.image.MemoryImageSource;
import java.awt.image.PixelGrabber;

class SlidingPuzzlePhoto extends Canvas
{

    public SlidingPuzzlePhoto(Image image, int i, int j, int k, int l, Applet applet)
    {
        registered = false;
        showCopyright = false;
        shadowup = new Color(220, 220, 220);
        shadowdown = new Color(50, 50, 50);
        delay = 20;
        gameover = false;
        target = -1;
        targetx = 0;
        targety = 0;
        mouseover = -1;
        moves = 0;
        movex = -1;
        movey = -1;
        best = 9999;
        sw1 = -1;
        sw2 = -1;
        transit = 0;
        maxtransit = 10;
        oldrow = 0;
        oldcol = 0;
        soff = 5;
        bMoveAll = false;
        pic = image;
        app = applet;
        width = i;
        height = j;
        row = k;
        col = l;
        resize(i, j);
        data = new int[i * j];
        grabPixels();
        makePieces(k, l);
        repaint();
    }

    public void makePieces(int i, int j)
    {
        boolean flag = false;
        boolean flag1 = false;
        boolean flag2 = false;
        int j1 = 0;
        int k1 = 0;
        int l1 = 0;
        row = i;
        col = j;
        if(i == oldrow && j == oldcol)
            return;
        int i2 = i * j;
        w = width / j;
        h = height / i;
        pieces = null;
        pieces = new Image[i2];
        order = null;
        order = new int[i2];
        ordernew = new int[i2];
        int ai1[] = new int[i2];
        int ai2[] = new int[i2];
        shad = null;
        int ai[] = new int[w * h];
        for(int j2 = 0; j2 < i2; j2++)
        {
            int l = (j2 % j) * w;
            int i1 = (j2 / j) * h;
            for(int k2 = 0; k2 < h; k2++)
            {
                for(int i3 = 0; i3 < w; i3++)
                {
                    int k = (k2 + i1) * width + (i3 + l);
                    j1 = (data[k] & 0xff0000) >> 16;
                    k1 = (data[k] & 0xff00) >> 8;
                    l1 = data[k] & 0xff;
                    ai[k2 * w + i3] = (new Color(j1, k1, l1)).getRGB();
                }

            }

            pieces[j2] = createImage(new MemoryImageSource(w, h, ai, 0, w));
            for(ai1[j2] = ai2[j2] = -1; ai1[j2] < 0 || ai2[j2] < 0; ai2[j2] = pieces[j2].getHeight(this))
                ai1[j2] = pieces[j2].getWidth(this);

            order[j2] = j2;
            ordernew[j2] = j2;
        }

        j1 = k1 = l1 = 50;
        int l2 = 0 | (j1 & 0xff) << 16 | (k1 & 0xff) << 8 | l1 & 0xff;
        int j3 = 0xff000000 | (j1 & 0xff) << 16 | (k1 & 0xff) << 8 | l1 & 0xff;
        for(int k3 = 0; k3 < h; k3++)
        {
            for(int l3 = 0; l3 < w; l3++)
                if(l3 % 2 == 1 || k3 % 2 == 1)
                    ai[k3 * w + l3] = j3;
                else
                    ai[k3 * w + l3] = l2;

        }

        shad = createImage(new MemoryImageSource(w, h, ai, 0, w));
        for(ai1[0] = ai2[0] = -1; ai1[0] < 0 || ai2[0] < 0; ai2[0] = shad.getHeight(this))
            ai1[0] = shad.getWidth(this);

        oldrow = i;
        oldcol = j;
    }

    public void resetPositions()
    {
        boolean flag = false;
        int i = row * col;
        Graphics g = getGraphics();
        bMoveAll = true;
        sw1 = sw2 = -1;
        for(int j = 0; j < i; j++)
            ordernew[j] = order[j];

        soff = 5;
        for(int k = 1; k <= maxtransit; k++)
        {
            transit = k;
            paint(g);
            try
            {
                Thread.sleep(delay);
            }
            catch(Exception exception) { }
        }

        for(int l = 0; l < i; l++)
            order[l] = l;

        transit = 0;
        bMoveAll = false;
    }

    public void rescramble()
    {
        boolean flag = false;
        boolean flag1 = false;
        boolean flag2 = false;
        int l = row * col;
        Graphics g = getGraphics();
        bMoveAll = true;
        sw1 = sw2 = -1;
        int ai[] = new int[l];
        for(int i1 = 0; i1 < l; i1++)
            ai[i1] = order[i1];

        for(int j1 = 0; j1 < l; j1++)
        {
            int i = j1;
            int j = (int)(Math.round(Math.random() * 10D * (double)l * (double)l) % (long)l);
            if(i == j)
                j = (i + 1) % l;
            int k = ai[i];
            ai[i] = ai[j];
            ai[j] = k;
        }

        for(int k1 = 0; k1 < l; k1++)
        {
            for(int l1 = 0; l1 < l; l1++)
            {
                if(ai[l1] != order[k1])
                    continue;
                ordernew[k1] = l1;
                break;
            }

        }

        soff = 5;
        for(int i2 = 1; i2 <= maxtransit; i2++)
        {
            transit = i2;
            paint(g);
            try
            {
                Thread.sleep(delay);
            }
            catch(Exception exception) { }
        }

        for(int j2 = 0; j2 < l; j2++)
            order[j2] = ai[j2];

        transit = 0;
        bMoveAll = false;
    }

    public void update(Graphics g)
    {
        paint(g);
    }

    private void grabPixels()
    {
        PixelGrabber pixelgrabber = new PixelGrabber(pic, 0, 0, width, height, data, 0, width);
        try
        {
            pixelgrabber.grabPixels();
        }
        catch(InterruptedException interruptedexception) { }
    }

    public Dimension minimizeSize()
    {
        return new Dimension(width, height);
    }

    public Dimension preferredSize()
    {
        return new Dimension(width, height);
    }

    public Insets insets()
    {
        return new Insets(0, 0, 0, 0);
    }

    public void paint(Graphics g)
    {
        boolean flag = false;
        boolean flag1 = false;
        int i2 = row * col;
        if(og == null)
        {
            oi = createImage(width, height);
            og = oi.getGraphics();
        }
        og.setColor(bg);
        og.fillRect(0, 0, width, height);
        for(int j2 = 0; j2 < i2; j2++)
            if(order[j2] != i2 - 1 && j2 != target && j2 != sw1 && j2 != sw2)
                if(bMoveAll)
                {
                    int i = (j2 % col) * w;
                    int i1 = (j2 / col) * h;
                    int k2 = (ordernew[j2] % col) * w;
                    int i3 = (ordernew[j2] / col) * h;
                    i += (transit * (k2 - i)) / maxtransit;
                    i1 += (transit * (i3 - i1)) / maxtransit;
                    og.drawImage(shad, i + soff, i1 + soff, this);
                    og.drawImage(pieces[order[j2]], i - soff, i1 - soff, this);
                    og.setColor(shadowdown);
                    og.drawRect(i - soff, i1 - soff, w - 1, h - 1);
                } else
                {
                    int j = (j2 % col) * w;
                    int j1 = (j2 / col) * h;
                    og.drawImage(pieces[order[j2]], j, j1, this);
                    if(j2 == mouseover)
                        og.setColor(Color.red);
                    else
                        og.setColor(shadowdown);
                    og.drawRect(j, j1, w - 1, h - 1);
                }

        if(target > -1)
        {
            og.setColor(shadowdown);
            og.drawImage(shad, targetx + 10, targety + 10, this);
            og.drawImage(pieces[order[target]], targetx, targety, this);
            og.setColor(shadowdown);
            og.drawRect(targetx + 1, targety + 1, w - 2, h - 2);
            og.setColor(shadowup);
            og.drawRect(targetx, targety, w - 1, h - 1);
        } else
        if(sw1 > -1)
        {
            for(int l2 = 0; l2 < 2; l2++)
                if(l2 == 0 && order[sw1] != i2 - 1)
                {
                    int k = (sw1 % col) * w;
                    int k1 = (sw1 / col) * h;
                    int j3 = (sw2 % col) * w;
                    int j4 = (sw2 / col) * h;
                    k += (transit * (j3 - k)) / maxtransit;
                    k1 += (transit * (j4 - k1)) / maxtransit;
                    og.drawImage(shad, k + soff, k1 + soff, this);
                    og.drawImage(pieces[order[sw1]], k - soff, k1 - soff, this);
                    og.setColor(shadowdown);
                    og.drawRect(k - soff, k1 - soff, w - 1, h - 1);
                } else
                if(l2 == 1 && order[sw2] != i2 - 1)
                {
                    int l = (sw2 % col) * w;
                    int l1 = (sw2 / col) * h;
                    int k3 = (sw1 % col) * w;
                    int k4 = (sw1 / col) * h;
                    l += (transit * (k3 - l)) / maxtransit;
                    l1 += (transit * (k4 - l1)) / maxtransit;
                    og.drawImage(shad, l + soff, l1 + soff, this);
                    og.drawImage(pieces[order[sw2]], l - soff, l1 - soff, this);
                    og.setColor(shadowdown);
                    og.drawRect(l - soff, l1 - soff, w - 1, h - 1);
                }

        }
        if(movex > -1 && movey > -1)
        {
            og.setFont(new Font("Helvetica", 1, 11));
            String s = MovesCountText + " " + moves;
            og.setColor(Color.black);
            byte byte0 = 5;
            byte byte1 = 24;
            og.drawString(s, byte0, byte1 - 13);
            og.drawString(s, byte0, byte1 - 11);
            og.drawString(s, byte0 - 1, byte1 - 12);
            og.drawString(s, byte0 + 1, byte1 - 12);
            og.setColor(Color.white);
            og.drawString(s, byte0, byte1 - 12);
            String s3 = BestText + " " + best;
            if(best >= 9999)
                s3 = "";
            og.setColor(Color.black);
            og.drawString(s3, byte0, byte1 - 1);
            og.drawString(s3, byte0, byte1 + 1);
            og.drawString(s3, byte0 - 1, byte1);
            og.drawString(s3, byte0 + 1, byte1);
            og.setColor(Color.white);
            og.drawString(s3, byte0, byte1);
        }
        if(gameover)
        {
            if(moves < best)
                best = moves;
            og.setFont(new Font("Helvetica", 1, 20));
            String s1 = FinishText;
            int l3 = (width - og.getFontMetrics().stringWidth(s1)) / 2;
            int l4 = height / 2;
            og.setColor(Color.black);
            og.drawString(s1, l3, l4 - 1);
            og.drawString(s1, l3, l4 + 1);
            og.drawString(s1, l3 - 1, l4);
            og.drawString(s1, l3 + 1, l4);
            og.setColor(Color.white);
            og.drawString(s1, l3, l4);
        }
        if(!registered && showCopyright)
        {
            og.setFont(new Font("Helvetica", 1, 11));
            String s2 = "SlidingPuzzle (C) thejmaker.com 2002";
            int i4 = width - og.getFontMetrics().stringWidth(s2) - 4;
            int i5 = height - 5;
            og.setColor(Color.blue);
            og.drawString(s2, i4, i5 - 1);
            og.drawString(s2, i4, i5 + 1);
            og.drawString(s2, i4 - 1, i5);
            og.drawString(s2, i4 + 1, i5);
            og.setColor(Color.cyan);
            og.drawString(s2, i4, i5);
        }
        g.drawImage(oi, 0, 0, this);
    }

    public void animatedMove()
    {
        int i = maxtransit;
        Graphics g = getGraphics();
        soff = 0;
        maxtransit = 15;
        for(int j = 1; j <= maxtransit; j++)
        {
            transit = j;
            paint(g);
            try
            {
                Thread.sleep(delay);
            }
            catch(Exception exception) { }
        }

        sw1 = sw2 = -1;
        transit = 0;
        maxtransit = i;
    }

    public boolean mouseDown(Event event, int i, int j)
    {
        boolean flag = false;
        boolean flag1 = false;
        int i1 = -1;
        boolean flag2 = false;
        int j1 = row * col;
        for(int k1 = 0; k1 < j1; k1++)
        {
            int k = (k1 % col) * w;
            int l = (k1 / col) * h;
            if(i < k || i >= k + w || j < l || j >= l + h)
                continue;
            moveaudio.play();
            i1 = k1;
            break;
        }

        if(i1 > -1 && i1 % col != 0 && order[i1 - 1] == j1 - 1)
        {
            sw1 = i1;
            sw2 = i1 - 1;
            animatedMove();
            order[i1 - 1] = order[i1];
            order[i1] = j1 - 1;
            flag2 = true;
        }
        if(!flag2 && i1 > -1 && i1 % col != col - 1 && order[i1 + 1] == j1 - 1)
        {
            sw1 = i1;
            sw2 = i1 + 1;
            animatedMove();
            order[i1 + 1] = order[i1];
            order[i1] = j1 - 1;
            flag2 = true;
        }
        if(!flag2 && i1 > -1 && i1 / col >= 1 && order[i1 - col] == j1 - 1)
        {
            sw1 = i1;
            sw2 = i1 - col;
            animatedMove();
            order[i1 - col] = order[i1];
            order[i1] = j1 - 1;
            flag2 = true;
        }
        if(!flag2 && i1 > -1 && i1 / col < row - 1 && order[i1 + col] == j1 - 1)
        {
            sw1 = i1;
            sw2 = i1 + col;
            animatedMove();
            order[i1 + col] = order[i1];
            order[i1] = j1 - 1;
            flag2 = true;
        }
        if(flag2)
            moves++;
        repaint();
        if(moves > 0)
        {
            for(int l1 = 0; l1 < j1; l1++)
                if(order[l1] != l1)
                    return true;

            gameover = true;
        }
        return true;
    }

    public boolean mouseExit(Event event, int i, int j)
    {
        showCopyright = false;
        if(!registered)
            app.showStatus("SlidingPuzzle (C) thejmaker.com 2002");
        else
            app.showStatus("");
        repaint();
        movex = -1;
        movey = -1;
        mouseover = -1;
        return true;
    }

    public boolean mouseUp(Event event, int i, int j)
    {
        int k = row * col;
        if(target > -1)
        {
            int l = targetx + w / 2;
            int j1 = targety + h / 2;
            boolean flag = false;
            boolean flag1 = false;
            int i2 = target;
            int j2 = w * w + h * h;
            boolean flag2 = false;
            for(int i3 = 0; i3 < k; i3++)
            {
                int k1 = (i3 % col) * w + w / 2;
                int l1 = (i3 / col) * h + h / 2;
                int k2 = (l - k1) * (l - k1) + (j1 - l1) * (j1 - l1);
                if(k2 < j2)
                {
                    i2 = i3;
                    j2 = k2;
                }
            }

            if(target != i2)
                moves++;
            int l2 = order[target];
            order[target] = order[i2];
            order[i2] = l2;
            target = -1;
        }
        showCopyright = true;
        repaint();
        for(int i1 = 0; i1 < k; i1++)
            if(order[i1] != i1)
                return true;

        winaudio.play();
        gameover = true;
        return true;
    }

    public boolean mouseMove(Event event, int i, int j)
    {
        boolean flag = false;
        boolean flag1 = false;
        int i1 = row * col;
        for(int j1 = 0; j1 < i1; j1++)
        {
            int k = (j1 % col) * w;
            int l = (j1 / col) * h;
            if(i < k || i >= k + w || j < l || j >= l + h)
                continue;
            mouseover = j1;
            break;
        }

        movex = i;
        movey = j;
        showCopyright = true;
        if(registered)
            app.showStatus("");
        else
            app.showStatus("SlidingPuzzle (C) thejmaker.com 2002");
        repaint();
        return true;
    }

    Image oi;
    Graphics og;
    boolean registered;
    boolean showCopyright;
    Image pic;
    Color bg;
    Color shadowup;
    Color shadowdown;
    int delay;
    Applet app;
    int width;
    int height;
    int w;
    int h;
    int row;
    int col;
    int data[];
    Image pieces[];
    Image shad;
    boolean gameover;
    int order[];
    int ordernew[];
    int target;
    int targetx;
    int targety;
    int mouseover;
    int moves;
    int movex;
    int movey;
    int best;
    AudioClip winaudio;
    AudioClip moveaudio;
    String MovesCountText;
    String FinishText;
    String BestText;
    int sw1;
    int sw2;
    int transit;
    int maxtransit;
    int oldrow;
    int oldcol;
    int soff;
    boolean bMoveAll;
}

Link para o comentário
Compartilhar em outros sites

  • 0

tu tem os três arquivos no mesmo diretório?

Pelo que eu vi aqui, os códigos não contém erros, apenas algumas advertências que não tenho certeza do q se tratam.

Acredito que ele precisa dos 3 .class no mesmo diretório pois o principal não faz import dos outros dois.

Teteia ai...

estou indo pra casa

vai fuçando, quem sabe não encontra o erro.

Amanhã te respondo

Abraço

Crystian

Link para o comentário
Compartilhar em outros sites

  • 0

bom, o java script você teria q continuar usando, pra mandar submitar a página quando troca de valor no Select, dae dava pra tentar setar um campo hidden com o caminho da foto aí você envia pega em php a variavel setada e remonta a página.

É acredito q dê certo sim.

Só não me lembro como fazer isso em php, dá uma conversada com os caras de PHP aqui do fórum, vou tentar fazer em jsp.

Abraço

Crystian

Link para o comentário
Compartilhar em outros sites

  • 0

Crystian

laugh.gif Boas notícias! Eu consegui um grande progresso já. Dá uma olhada visitando o site: http://dhost.info/rebenta/gatas/teste3.php. O que ficou faltando agora é carregar a primeira foto na carga da página e manter o select com o valor selecionado antes do "submit" (ele retorna para o "_izoca" após o submit, ou seja, a primeira opção). De resto, o applet está funcionando.

Abaixo vai o código da referida página:

<html>
<head>
<script language="Javascript">
function mudaGata(id, value) {
  document.getElementById(id).value = value;
  document.frm.submit();
};
</script>
</head>
<body>
 <center>
 <table border="0" cellpadding="0" cellspacing="1" width="100%">
   <tr>
     <td width="50%">
       <p align="left"> Escolher gata:
 <form name="frm">
        <input type="text" name="nome" onBlur="tel(this)">
           <select name="select" onChange="mudaGata('foto', this.options[this.selectedIndex].value);">
             <option value="images/_izoca.jpg" selected>images/_izoca.jpg</option>
             <option value="images/anazuca.jpg">images/anazuca.jpg</option>
             <option value="images/aninhabdl.jpg">images/aninhabdl.jpg</option>
             <option value="images/brunenhaa.jpg">images/brunenhaa.jpg</option>
             <option value="images/carolinabela.jpg">images/carolinabela.jpg</option>
             <option value="images/claufreak.jpg">images/claufreak.jpg</option>
             <option value="images/dessaribas.jpg">images/dessaribas.jpg</option>
             <option value="images/ellen.jpg">images/ellen.jpg</option>
             <option value="images/grazinha.jpg">images/grazinha.jpg</option>
             <option value="images/mozuda.jpg">images/mozuda.jpg</option>
             <option value="images/nathaliah.jpg">images/nathaliah.jpg</option>
             <option value="images/tezinhaa.jpg">images/tezinhaa.jpg</option>
             <option value="images/um_s_na_estrela.jpg">images/um_s_na_estrela.jpg</option>
             <option value="images/vanihhh.jpg">images/vanihhh.jpg</option>
           </select></p>
           <?php
           $select = $_GET["select"];
          echo "<applet code='SlidingPuzzle.class' archive='SlidingPuzzle.jar' width='600' height='590'>
               <param name=regcode value='99999999'>
               <!-- number of frames in the animation of swapping pieces --><param name=frames value='30'>
               <!-- animation delay between frames in milliseconds --><param name=delay value='20'>
               <!-- photo file for the puzzle --><param id='foto' name='photo' value='$select'>
               <!-- toggle to start with a scrambled mode (0 = no init scarmble) --><param name=scramblestart value='1'>
               <!-- winning audio filename --><param name=winfile value='SlidingPuzzle1.au'>
               <!-- moving audio filename --><param name=movefile value='SlidingPuzzle2.au'>
               <!-- panel background color: R G B --><param name=panelbg value='143 31 192'>
               <!-- panel foreground color: R G B --><param name=panelfg value='255 199 0'>
               <!-- button background color: R G B --><param name=buttonbg value='255 199 0'>
               <!-- button foreground color: R G B --><param name=buttonfg value='0 0 0'>
               <!-- '|' seperates gameover URL and target frame -->
               <!-- fill in 'none' for URL if  you don't want any URL -->
               <!-- target frame options are as follows -->
               <!-- _self   = current frame -->
               <!--_parent = parent frame -->
               <!--       _top    = top-most frame -->
               <!--       _blank  = new unnamed top-level frame -->
               <!--       x       = new top-level frame named x -->
               <param name=linkto value='none|_self'>
               <!-- number of rows and columns to divide the puzzle -->
               <!-- Note. Please make sure puzzle width and height are divisible by row and col.-->
               <param name=row value='4'><param name=col value='5'>
               <!-- all text strings --><param name=TitleText value='Quebra Cabe&ccedil;a de Gatas'>
               <param name=NewGameText value='Misturar'>
               <param name=SolvePuzzleText value='Resolver'>
               <param name=MovesCountText  value='Contador:'>
               <param name=BestText value='O melhor desempenho:'>
               <param name=FinishText value='Voc&ecirc; conseguiu montar uma gata!'>
           </applet><!------COPY AND PASTE THE CODE ABOVE THIS LINE----------------------------->";
           ?>
     </form></td>
     <td width="50%">
   </td>
   </tr>
 </table>
 </center>
</body>
</html>

Link para o comentário
Compartilhar em outros sites

  • 0

É assim mesmo que tem q se faze, não desistir...hehehehe

tu tah utilizando alguma linguagem dinâmica (PHP, ASP, JSP)? ... se não tiver tu vai ter que passar variaveis através do location para dizer qual é a option que tah selecionada.

Abraço

Crystian

PS.: ainda não consegui ver o applet, não consegui baixar o plugin para o mozilla.

Link para o comentário
Compartilhar em outros sites

  • 0

Oi Crystian

É, na base da porretada está indo, ehehe. O applet está processando as imagens sem travar..o que ocorre é que a primeira imagem ele não processa (quando a página é carregada na primeira vez). E têm uma ou outra foto que estranhamente não carregam.

Eu to usando php só para pegar o valor postado na url e imprimir as tags do applet. O tratamento do submit ainda é javascript e a página é impressa normalmente html (sem usar o php para escrevê-la). Como devo proceder para manter o select na página submitada então?

Link para o comentário
Compartilhar em outros sites

  • 0

Utiliza uma variavel no php que pega o valor do select e depois seta. Faz tempo que não mexo com php desde q terminei a faculdade não mexo mais. Então é melhor tu pedir pra alguém do PHP.

agente até podia fazer com javascript, mas dá bem mais trabalho, não vale a pena, utiliza php que tu mata a charada!

quanto a primeira vez não carregar a imagem é estranho porque o parâmetro photo é passado, não entendo como ele não está carregando, tenho q dar mais uma olhada.

Até

Crystian

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152k
    • Posts
      651,8k
×
×
  • Criar Novo...