![]() |
![]() |
![]() |
![]() |
|
|||||
applets JAVA |
|||||
y Fruti |
Maestro |
COLORES Y TAMAÑOS
///////////////////////////////////////////////
// Java 2 APPLET zRotulo.java
// Wilucha 09/09/02
//////////////////////////////////////////////
import java.awt.Graphics;
import java.awt.Font;
import java.awt.Color;
public class zRotulo extends java.applet.Applet {
Font TipoFont = new Font("TimesRoman", Font.BOLD, 30);
Font TipoFon2 = new Font("Arial", Font.BOLD, 16);
Font TipoFon3 = new Font("Verdana", Font.BOLD, 10);
public void paint(Graphics screen) {
setBackground(Color.blue);
screen.setFont(TipoFont);
screen.setColor(Color.magenta);
int Xrotulo=10;
int Yrotulo=30;
screen.drawString("TimesRoman 30 magenta", Xrotulo, Yrotulo);
screen.setFont(TipoFon2);
screen.setColor(Color.yellow);
int Yrotul2=80;
screen.drawString("Rotulo Arial 16 yellow", Xrotulo, Yrotul2);
screen.setFont(TipoFon3);
screen.setColor(Color.cyan);
int Yrotul3=100;
screen.drawString("Rotulo Verdana 10 cyan", Xrotulo, Yrotul3);
screen.setColor(Color.orange);
int Yrotul4=120;
screen.drawString("Rotulo Verdana 10 orange", Xrotulo, Yrotul4);
screen.setColor(Color.pink);
int Yrotul5=130;
screen.drawString("Rotulo Verdana 10 pink", Xrotulo, Yrotul5);
}
}
En el siguiente renglon tienes este applets en acción..!!
APPLETS CON IMAGEN
DESCARGAR APPLET: zRotulo.class
FUENTE: zRotulo.java
Activa tu editor y copia textualmente el siguiente código
///////////////////////////////////////////////
// Java 2 APPLET zFotoWilo.java
// Wilucha 05/08/02
//////////////////////////////////////////////
import java.awt.Graphics;
import java.awt.Image;
public class zFotoWilo extends java.applet.Applet {
Image wilo;
public void init()
{
wilo = getImage(getCodeBase(),
"aWilucha.jpg");
}
public void paint(Graphics screen)
{
int AnchoFoto = wilo.getWidth(this);
int AltoFoto = wilo.getHeight(this);
int AbsisaFoto = 10;
int OrdenadaFoto = 10;
// Mostrar foto en tamaño 1/4
screen.drawImage(wilo, AbsisaFoto, OrdenadaFoto,
AnchoFoto / 4, AltoFoto / 4, this);
}
}
En el siguiente renglon tienes este applets en acción..!!
APPLETS TUTI
DESCARGAR APPLET: zFotoWilo.class
FUENTE: zFotoWilo.java
Activa tu editor y copia textualmente el siguiente código
///////////////////////////////////////////////
// Java 2 APPLET zFotoRotulo.java
// Wilucha 07/08/02
//////////////////////////////////////////////
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Font;
import java.awt.Image;
public class zFotoRotulo extends java.applet.Applet
implements Runnable {
Font TipoLetra = new Font("TimesRoman", Font.BOLD, 50);
Color ColorActual[] = new Color[50];
Thread Activo;
Image wilo;
public void init() {
wilo = getImage(getCodeBase(),
"aWilucha.jpg");
}
public void start() {
if (Activo == null) {
Activo = new Thread(this);
Activo.start();
}
}
public void stop() {
Activo = null;
}
public void run() {
float c = 0;
for (int i = 0; i < ColorActual.length; i++) {
ColorActual[i] =
Color.getHSBColor(c, (float)1.0,(float)1.0);
c += .02;
}
int i = 0;
Thread thisThread = Thread.currentThread();
while (Activo == thisThread) {
setForeground(ColorActual[i]);
repaint();
i++;
try {
Thread.sleep(200);
} catch (InterruptedException e) { }
if (i == ColorActual.length ) i = 0;
}
}
public void paint(Graphics screen)
{
int AnchoFoto = wilo.getWidth(this);
int AltoFoto = wilo.getHeight(this);
int AbsisaFoto = 10;
int OrdenadaFoto = 10;
screen.drawImage(wilo, AbsisaFoto, OrdenadaFoto,
AnchoFoto / 4, AltoFoto / 4, this);
screen.setFont(TipoLetra);
int Xrotulo=5;
int Yrotulo=90;
screen.drawString("Paradigmas", Xrotulo, Yrotulo);
}
}
En el siguiente renglon tienes este applets en acción..!!
COLOR DE FONDO
DESCARGAR APPLET: zFotoRotulo.class
FUENTE: zFotoRotulo.java
Activa tu editor y copia textualmente el siguiente código
///////////////////////////////////////////////
// Java 2 APPLET zFondoColor.java
// Wilucha 09/09/02
//////////////////////////////////////////////
import java.awt.*;
public class zFondoColor extends java.applet.Applet {
Button rojoBoton,azulBoton,verdeBoton,blancoBoton,negroBoton;
public void init() {
setBackground(Color.white);
setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10));
rojoBoton = new Button("Rojo");
add(rojoBoton);
azulBoton = new Button("Azul");
add(azulBoton);
verdeBoton = new Button("Verde");
add(verdeBoton);
blancoBoton = new Button("Blanco");
add(blancoBoton);
negroBoton = new Button("Negro");
add(negroBoton);
}
public boolean action(Event evt, Object arg) {
if (evt.target instanceof Button) {
changeColor((Button)evt.target);
return true;
} else return false;
}
void changeColor(Button botonActivo) {
if (botonActivo == rojoBoton) setBackground(Color.red);
else if (botonActivo == azulBoton) setBackground(Color.blue);
else if (botonActivo == verdeBoton) setBackground(Color.green);
else if (botonActivo == blancoBoton) setBackground(Color.white);
else setBackground(Color.black);
repaint();
}
}
MUSICA MAESTRO
DESCARGAR APPLET: zFondoColor.class
FUENTE: zFondoColor.java
Java tambien te permite reproducir tu música a través de los Applets:
Puedes lograr que el audio se reproduza una sola vez
Puedes hacer que se repita continuamente mediante un bucle de iteración
Java 2 te permite reproducir los siguientes formatos de música digitalizada:
Colega virtual, si eres amigo del ruido te permite recuperar tus sonidos, mediante el método play() de Java que toma las siguientes formas:
Con un argumente play() carga y reproduce un espacio de audio almacenado en el mismo URL.
play() con dos argumentos (Un URL y un path) carga y reproduce un espacio de audio.
El primer argumento llama a getDocumentBase() o getCodeBase().
Ejemplo:
play(getCodeBase(),"MiRitmo.au")
Recupera y reproduce los sonidos de MiRitmo.au
Para recuperar y reproducir tu música dentro de un applet, préviamente debes cargarlo en el objeto AudioClip, como puedes apreciar en el siguiente ejemplo:
AudioClip MiClip = getAudioClip(getCodeBase(),"MiRitmo.au")
Para recuperar y reproducir tu música dentro de una aplicación, préviamente debes cargarlo en el objeto AudioClip, como puedes apreciar en el siguiente ejemplo:
AudioClip MiClip = newAudioClip("MiRitmo.au")
Luego de crear el objeto AudioClip, ya puedes operar los comandos:
Finalmente te cuento que puedes reproducir más de un sonido.
Copia textualmente la siguiente sintaxis:
///////////////////////////////////////////////
// Java 2 APPLET zAudio.java
// Wilucha 13/07/03
//
//////////////////////////////////////////////
import java.awt.Graphics;
import java.applet.AudioClip;
public class zAudio extends java.applet.Applet
implements Runnable {
AudioClip SonidoFondo;
AudioClip OtroSonido;
Thread MusicaMaestro;
public void start() {
if (MusicaMaestro == null) {
MusicaMaestro = new Thread(this);
MusicaMaestro.start();
}
}
public void stop() {
if (MusicaMaestro != null) {
if (SonidoFondo != null)
SonidoFondo.stop();
MusicaMaestro = null;
}
}
public void init() {
SonidoFondo = getAudioClip(getCodeBase(),"zLoop.au");
OtroSonido = getAudioClip(getCodeBase(), "zMusicaSpace.au");
}
public void run() {
if (SonidoFondo != null)
SonidoFondo.loop();
Thread thisThread = Thread.currentThread();
while (MusicaMaestro == thisThread) {
try {
Thread.sleep(5000);
} catch (InterruptedException e) { }
if (OtroSonido != null)
OtroSonido.play();
}
}
public void paint(Graphics screen) {
screen.drawString("Música maestro ...", 10, 10);
}
}
DESCARGAR APPLET: zAudio.class
FUENTE: zAudio.java