[3544] in java-interest

home help back first fref pref prev next nref lref last post

Invasion de memoria ?

daemon@ATHENA.MIT.EDU (Victor Anorga)
Wed Nov 15 21:49:18 1995

From: "Victor Anorga" <VANORGA@beta.upc.edu.pe>
To: java-interest-digest@java.sun.com
Date:          Wed, 15 Nov 1995 18:44:33 EST

Hola gente de java

  Recien empiezo y tengo algunos problemas que espero alguno de ustedes me ayuden a resolver.

He agragado algunas cosas al  demo NervousText.java

Compilo el programa con el javac.exe y lo ejecuto con el 
appletviewer.exe.

aqui el codigo :

import java.awt.Font;
import java.awt.Color;
import java.awt.Graphics;

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

  char strseparado[];
  String xstr = null, xtemp = null;
  Thread killme = null;
  int i, x_coord = 0, y_coord = 0;
  boolean threadSuspendido = false;
  Font font;

  public void init() {
    resize(640, 200);
    setFont(font = new java.awt.Font("TimesRoman", Font.ITALIC, 36));
    xstr = getParameter("text");
    if (xstr == null) {
       xstr = "Victor Anorga Zavala";
    }

    strseparado  =  new char [xstr.length()];
    xstr.getChars(0, xstr.length(), strseparado, 0);
    xtemp = "Victor Manuel Anorga Zavala - ";
  }

  .
  .
  .
  /* aqui viene Start, Stop, Run */
  .
  .
  .

  public void paint(Graphics g) {
    /* al ejecutarse esta linea estoy invadiendo memoria ???? */

    xtemp = xtemp.substring(xtemp.length(), 1) + xtemp.substring(0, 
xtemp.length() - 1); 

    /* el programa empieza a ejecutarse y luego de mostrar la cadena 
dando vueltas debajo del texto nervioso me dice que el programa ha 
invadido memoria. Es esto posible o se trata de otra cosa ??? */

    g.drawString(xtemp, 1, 90);

    for(i = 0; i < xstr.length(); i++) {
       int x = 0, y = font.getSize();
       int red = (int)(Math.random() * 256);
       int green = (int)(Math.random() * 256);
       int blue = (int)(Math.random() * 256);

       x_coord = (int) (Math.random() * 10 + 15 * i);
       y_coord = (int) (Math.random() * 10 + 36);

       g.setColor(new java.awt.Color((red + y * 30) % 256, (green + x * 30) % 256, (blue + y * 30) % 256));
       g.drawChars(strseparado, i, 1, x_coord, y_coord);
      }
  }
 
  public boolean mouseDown(java.awt.Event evt, int x, int y) {
    if (threadSuspendido) {
       killme.resume();
    } else {
       killme.suspend();
    }
    threadSuspendido = !threadSuspendido;
    return true;
  }
}

Este programa invade memoria al con la instruccion ??? :

    xtemp = xtemp.substring(xtemp.length(), 1) + xtemp.substring(0, 
xtemp.length() - 1); 

Tengo otra duda : Cualdo ejecuto el appletviewer con el 
nombreprograma.class como parametro me sale el mensaje :
[no properties loaded, using defaults]

es esto normal ?

Cualquier ayuda sera bien recibida.

Victor Anorga Zavala

/************************************************************
 UNIVERSIDAD PERUANA DE CIENCIAS APLICADAS
  Departamento de Multimedia
   VICTOR MANUEL ANORGA ZAVALA
    E-mail : vanorga@beta.upc.edu.pe
************************************************************/
   
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post