Foros del Web » Programación para mayores de 30 ;) » Java »

Problemas de link en un applet

Estas en el tema de Problemas de link en un applet en el foro de Java en Foros del Web. Hola a todos tengo un problema con un banner que trabaja con java y a medida que pasan los nombres de los sitios cada uno ...
  #1 (permalink)  
Antiguo 12/11/2004, 09:00
Avatar de Funk  
Fecha de Ingreso: septiembre-2003
Ubicación: BA - Argentina
Mensajes: 102
Antigüedad: 20 años, 8 meses
Puntos: 0
Problemas de link en un applet

Hola a todos tengo un problema con un banner que trabaja con java y a medida que pasan los nombres de los sitios cada uno tiene su link correspondiente al sitio mencionado.

el tema es el siguiente si la direccion URL del sitio es absoluta "http://www.sitio.com", funciona perfectamente, pero si lo que quiero cn el banner es linkear una pagina dentro del mismo sitio por ejemplo contact.html, no funciona.

Les dejo el código con el cual estoy trabajando, mas el .class.

Código:
<APPLET CODE=GeoBanner.class WIDTH=609 HEIGHT=25>
        <param name="TextToDisplay" value="
nombre del link;
nombre del link;
nombre del link
">
        <param name="URLtoDisplay" value="
http://www.sitio.com; <!--  Asi funciona -->
contacto.html; <!--  Asi no funciona -->
http://www.sitio.com
">
        <param name="Target" value="principal">
        <param name="Transition" value="CENTER; LEFT; RIGHT">
        <param name="FontSize" value="22">
        <param name="FontStyle" value="italic">
        <param name="FontName" value="TimesRoman">
        <param name="Delay" value="2000">
        <param name="bgCOLOR1" value="155,200,130">
        <param name="bgCOLOR2" value="200,100,100">
        <param name="textCOLOR" value="0,0,0">
        Your browser doesn't support java or java is not enabled! </APPLET>
Bueno desde ya muchisimas gracias por el tiempo y por la ayuda.

Saludos
__________________
Walter Bove
Diseñador Multimedial
Arteuz Comunicación Multimedial
Funk Blog Job
  #2 (permalink)  
Antiguo 12/11/2004, 09:40
Avatar de hugo777  
Fecha de Ingreso: enero-2002
Ubicación: Lima, Perú
Mensajes: 757
Antigüedad: 22 años, 3 meses
Puntos: 1
Hola, creo que la respuesta puede estar en el codigo que este utilizando para llamar a la URL, puedes mostrarnos el código que lo hace dentro del applet?
__________________
Saludos,

H@C..
  #3 (permalink)  
Antiguo 12/11/2004, 09:42
Avatar de Funk  
Fecha de Ingreso: septiembre-2003
Ubicación: BA - Argentina
Mensajes: 102
Antigüedad: 20 años, 8 meses
Puntos: 0
Ya te lo pongo
gracias
__________________
Walter Bove
Diseñador Multimedial
Arteuz Comunicación Multimedial
Funk Blog Job
  #4 (permalink)  
Antiguo 12/11/2004, 12:22
Avatar de Funk  
Fecha de Ingreso: septiembre-2003
Ubicación: BA - Argentina
Mensajes: 102
Antigüedad: 20 años, 8 meses
Puntos: 0
parte1

Código:
import java.applet.Applet;
import java.applet.AppletContext;
import java.awt.*;
import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.StringTokenizer;
import java.util.Vector;

public class GeoBanner extends Applet
    implements Runnable
{

    public void init()
    {
        I = 0;
        g = new Vector(12, 10);
        h = new Vector(12, 10);
        i = new Vector(12, 10);
        A();
        S = (String)g.elementAt(0);
        setBackground(d);
        C = getSize().width;
        D = getSize().height;
        N = C / D;
        R = new Font(U, Q, H);
        Z = getFontMetrics(R);
        F = Z.stringWidth(S);
        E = (D - Z.getHeight()) / 2 + Z.getAscent();
        G = (C - F) / 2;
        u = new int[O];
        a = createImage(C, D);
        b = a.getGraphics();
        b.setFont(R);
        for(int i1 = 0; i1 < O; i1++)
        {
            String s1 = (String)i.elementAt(i1);
            if(s1.equalsIgnoreCase("RIGHT"))
                u[i1] = 2;
            else
            if(s1.equalsIgnoreCase("CENTER"))
                u[i1] = 1;
            else
            if(s1.equalsIgnoreCase("DOWN"))
                u[i1] = 3;
            else
            if(s1.equalsIgnoreCase("UP"))
                u[i1] = 5;
            else
            if(s1.equalsIgnoreCase("LEFT"))
                u[i1] = 4;
            else
            if(s1.equalsIgnoreCase("UP_LEFT"))
                u[i1] = 6;
            else
            if(s1.equalsIgnoreCase("UP_RIGHT"))
                u[i1] = 7;
            else
            if(s1.equalsIgnoreCase("DOWN_LEFT"))
                u[i1] = 8;
            else
            if(s1.equalsIgnoreCase("DOWN_RIGHT"))
                u[i1] = 9;
            else
            if(s1.equalsIgnoreCase("X_DIRECTION"))
                u[i1] = 10;
            else
            if(s1.equalsIgnoreCase("Y_DIRECTION"))
                u[i1] = 11;
            else
                u[i1] = 1;
        }

        v = u[0];
    }

    public void A()
    {
        S = getParameter("TextToDisplay");
        if(S == null)
            S = "Please Specify String;Questions to;[email protected]";
        O = C(S, g);
        S = getParameter("URLtoDisplay");
        if(S == null)
            S = "http://egnatia.ee.auth.gr/~gele/geojava/geojava.html;http://egnatia.ee.auth.gr/~gele/geojava/geojava.html;http://egnatia.ee.auth.gr/~gele/geojava/geojava.html";
        int i1 = C(S, h);
        S = getParameter("Transition");
        if(S == null)
            S = "CENTER;RIGHT;DOWN";
        int j1 = C(S, i);
        if(O != i1)
            System.out.println("Number of Strings and number of URLs differ. Please check parameters");
        if(O != j1)
            System.out.println("Number of Strings and number of transitions differ. Please check parameters");
        T = getParameter("FontSize");
        if(T == null)
            H = 24;
        else
            H = Integer.parseInt(T);
        U = getParameter("FontName");
        if(U == null)
            U = "TimesRoman";
        String s3 = getParameter("FontStyle");
        if(s3 == null)
            Q = 1;
        else
        if(s3.equalsIgnoreCase("PLAIN"))
            Q = 0;
        else
        if(s3.equalsIgnoreCase("BOLD"))
            Q = 1;
        else
        if(s3.equalsIgnoreCase("ITALIC"))
            Q = 2;
        else
        if(s3.equalsIgnoreCase("BOLDandITALIC"))
            Q = 3;
        else
            Q = 1;
        V = getParameter("bgCOLOR1");
        if(V == null)
            c = Color.red;
        else
        if((c = B(V)) == null)
            c = Color.blue;
        W = getParameter("bgCOLOR2");
        if(W == null)
            d = Color.blue;
        else
        if((d = B(W)) == null)
            d = Color.red;
        X = getParameter("textCOLOR");
        if(X == null)
            e = Color.black;
        else
        if((e = B(X)) == null)
            e = Color.black;
        String s4 = getParameter("Delay");
        if(s4 == null)
            P = 1000;
        else
            P = Integer.parseInt(s4);
        Y = getParameter("Target");
        if(Y == null)
            Y = "_blank";
        String s2 = getParameter("Author");
        if(s2 == null || !s2.equals("George Eleftheriou"))
        {
            e = Color.black;
            c = Color.black;
            d = Color.black;
        }
        String s1 = getParameter("Email");
        if(s1 == null || !s1.equals("[email protected]"))
        {
            e = Color.black;
            c = Color.black;
            d = Color.black;
        }
    }
__________________
Walter Bove
Diseñador Multimedial
Arteuz Comunicación Multimedial
Funk Blog Job
  #5 (permalink)  
Antiguo 12/11/2004, 12:23
Avatar de Funk  
Fecha de Ingreso: septiembre-2003
Ubicación: BA - Argentina
Mensajes: 102
Antigüedad: 20 años, 8 meses
Puntos: 0
parte2

Código:
public Color B(String s1)
    {
        int i1;
        int j1;
        int k1;
        try
        {
            i1 = Integer.parseInt(s1.substring(0, s1.indexOf(",")).trim());
            j1 = Integer.parseInt(s1.substring(s1.indexOf(",") + 1, s1.lastIndexOf(",")).trim());
            k1 = Integer.parseInt(s1.substring(s1.lastIndexOf(",") + 1).trim());
        }
        catch(NumberFormatException numberformatexception)
        {
            System.out.println("can't convert to integer, Switching to default colors" + numberformatexception);
            return null;
        }
        try
        {
            return new Color(i1, j1, k1);
        }
        catch(IllegalArgumentException illegalargumentexception)
        {
            System.out.println("can't create new color, Switching to default colors" + illegalargumentexception);
        }
        return null;
    }

    public int C(String s1, Vector vector)
    {
        StringTokenizer stringtokenizer = new StringTokenizer(s1, ";", false);
        int i1;
        for(i1 = 0; stringtokenizer.hasMoreTokens(); i1++)
        {
            String s2 = stringtokenizer.nextToken().trim();
            vector.addElement(s2);
        }

        return i1;
    }

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

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

    public void run()
    {
        do
        {
            if(v == 1)
            {
                J = C / 2;
                K = D / 2;
                L = 0;
                for(M = 0; J > -N; M += 2)
                {
                    repaint();
                    try
                    {
                        Thread.sleep(50L);
                    }
                    catch(InterruptedException _ex) { }
                    J -= N;
                    K--;
                    L += N * 2;
                }

                f = c;
                c = d;
                d = f;
            } else
            if(v == 4)
            {
                J = 0;
                K = 0;
                L = 0;
                M = D;
                for(; L < C + N; L += N)
                {
                    repaint();
                    try
                    {
                        Thread.sleep(50L);
                    }
                    catch(InterruptedException _ex) { }
                }

                f = c;
                c = d;
                d = f;
            } else
            if(v == 2)
            {
                J = C;
                K = 0;
                L = C;
                M = D;
                for(; J > -N; J -= N)
                {
                    repaint();
                    try
                    {
                        Thread.sleep(50L);
                    }
                    catch(InterruptedException _ex) { }
                }

                f = c;
                c = d;
                d = f;
            } else
            if(v == 5)
            {
                J = 0;
                K = 0;
                L = C;
                for(M = 0; M < D + 2; M += 2)
                {
                    repaint();
                    try
                    {
                        Thread.sleep(50L);
                    }
                    catch(InterruptedException _ex) { }
                }

                f = c;
                c = d;
                d = f;
            } else
            if(v == 3)
            {
                J = 0;
                K = D;
                L = C;
                M = D;
                for(; K > -2; K -= 2)
                {
                    repaint();
                    try
                    {
                        Thread.sleep(50L);
                    }
                    catch(InterruptedException _ex) { }
                }

                f = c;
                c = d;
                d = f;
            } else
            if(v == 8)
            {
                J = 0;
                K = D;
                L = 0;
                for(M = 0; K > -2; M += 2)
                {
                    repaint();
                    try
                    {
                        Thread.sleep(50L);
                    }
                    catch(InterruptedException _ex) { }
                    K -= 2;
                    L += N * 2;
                }

                f = c;
                c = d;
                d = f;
            } else
            if(v == 9)
            {
                J = C;
                K = D;
                L = 0;
                for(M = 0; J > -2 * N; M += 2)
                {
                    repaint();
                    try
                    {
                        Thread.sleep(50L);
                    }
                    catch(InterruptedException _ex) { }
                    J -= 2 * N;
                    K -= 2;
                    L += N * 2;
                }

                f = c;
                c = d;
                d = f;
            } else
            if(v == 7)
            {
                J = C;
                K = 0;
                L = 0;
                for(M = 0; J > -2 * N; M += 2)
                {
                    repaint();
                    try
                    {
                        Thread.sleep(50L);
                    }
                    catch(InterruptedException _ex) { }
                    J -= 2 * N;
                    L += N * 2;
                }

                f = c;
                c = d;
                d = f;
            } else
            if(v == 6)
            {
                J = 0;
                K = 0;
                L = 0;
                for(M = 0; L < C + 2 * N; M += 2)
                {
                    repaint();
                    try
                    {
                        Thread.sleep(50L);
                    }
                    catch(InterruptedException _ex) { }
                    L += N * 2;
                }

                f = c;
                c = d;
                d = f;
            } else
            if(v == 10)
            {
                J = C / 2;
                K = 0;
                L = 0;
                M = D;
                while(J > -N) 
                {
                    repaint();
                    try
                    {
                        Thread.sleep(50L);
                    }
                    catch(InterruptedException _ex) { }
                    J -= N;
                    L += N * 2;
                }
                f = c;
                c = d;
                d = f;
            } else
            if(v == 11)
            {
                J = 0;
                K = D / 2;
                L = C;
                for(M = 0; K > -N; M += 2 * N)
                {
                    repaint();
                    try
                    {
                        Thread.sleep(50L);
                    }
                    catch(InterruptedException _ex) { }
                    K -= N;
                }

                f = c;
                c = d;
                d = f;
            }
            try
            {
                Thread.sleep(P);
            }
            catch(InterruptedException _ex) { }
            I++;
            if(I > O - 1)
                I = 0;
            v = u[I];
        } while(true);
    }

    public void paint(Graphics g1)
    {
        b.setColor(c);
        b.setClip(J, K, L, M);
        b.fillRect(J, K, L, M);
        b.setColor(e);
        S = (String)g.elementAt(I);
        F = Z.stringWidth(S);
        G = (C - F) / 2;
        b.drawString(S, G, E);
        g1.drawImage(a, 0, 0, this);
    }

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

    public boolean mouseDown(Event event, int i1, int j1)
    {
        try
        {
            getAppletContext().showDocument(new URL((String)h.elementAt(I)), Y);
        }
        catch(MalformedURLException _ex)
        {
            System.out.println("Wrong URL");
        }
        return true;
    }

    public GeoBanner()
    {
    }

    Thread A;
    int B;
    int C;
    int D;
    int E;
    int F;
    int G;
    int H;
    int I;
    int J;
    int K;
    int L;
    int M;
    int N;
    int O;
    int P;
    int Q;
    Font R;
    String S;
    String T;
    String U;
    String V;
    String W;
    String X;
    String Y;
    FontMetrics Z;
    Image a;
    Graphics b;
    Color c;
    Color d;
    Color e;
    Color f;
    Vector g;
    Vector h;
    Vector i;
    final int j = 2;
    final int k = 3;
    final int l = 1;
    final int m = 4;
    final int n = 5;
    final int o = 6;
    final int p = 7;
    final int q = 8;
    final int r = 9;
    final int s = 10;
    final int t = 11;
    int u[];
    int v;
}
__________________
Walter Bove
Diseñador Multimedial
Arteuz Comunicación Multimedial
Funk Blog Job
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 01:41.