Segundo departamental.
Free Web Site - Free Web Space and Site Hosting - Web Hosting - Internet Store and Ecommerce Solution Provider - High Speed Internet
Search the Web


/*
<applet code = "Casillas.class" width = 300 height = 100>
</applet>
*/

import java.awt.*;
import java.applet.Applet;

public class Casillas extends Applet{

TextField t;
Font f;
Checkbox checa1;
Checkbox checa2;


public void init(){

checa1= new Checkbox("Negrita");
checa2= new Checkbox();

checa2.setLabel("Cursiva");

t = new TextField(10);
f = new Font("TimesRoman", Font.PLAIN, 14);

t.setFont(f);
add(t);
add(checa1);
add(checa2);
}

public boolean action(Event e, Object o){

int b, i;

if(e.target instanceof Checkbox){

if(checa1.getState() == true)
b = Font.BOLD;
else
b = Font.PLAIN;

if(checa2.getState() == true)
i = Font.ITALIC;
else
i = Font.PLAIN;

f = new Font("TimesRoman", b+i, 14);
t.setFont(f);

}
return true;
}
}




import java.awt.*;
import java.io.*;


public class Frame1 extends Frame{

TextField cajanombre, cajaedad, cajatelefono;
Label etinombre, etiedad, etitelefono;
Button botlimpiar, botaceptar, botguardar, botleer;
Checkbox checmovil, checdistribuido, checweb, checprogramacion, checservidor, checbd;
TextArea textdatos;
Archivos archivo1;

Frame1(){

super("Captura de datos");

cajanombre = new TextField(15);
cajaedad = new TextField(15);
cajatelefono = new TextField(15);

etinombre = new Label("Nombre");
etiedad = new Label("Edad");
etitelefono = new Label("Telefono");

botlimpiar = new Button("Limpiar");
botaceptar = new Button("Aceptar");
botguardar = new Button("Guardar");
botleer = new Button("Leer");

checmovil = new Checkbox("Computo movil");
checdistribuido = new Checkbox("Computo Distribuido");
checweb = new Checkbox("Web");
checprogramacion = new Checkbox("Programacion");
checservidor = new Checkbox("Cliente / Servidor");
checbd = new Checkbox("Bases de Datos");

textdatos = new TextArea(10,35);
textdatos.setText("");

archivo1 = new Archivos("d:\datos.dat");

add(etinombre);add(cajanombre); add(etiedad);add(cajaedad); add(etitelefono);add(cajatelefono);
add(checmovil); add(checdistribuido); add(checweb); add(checprogramacion); add(checservidor); add(checbd);
add(botlimpiar); add(botaceptar); add(botguardar); add( botleer);
add(textdatos);

setLayout(new FlowLayout());
resize(300,300);
show();
}

public boolean handleEvent(Event e){

if(e.id == Event.WINDOW_DESTROY){
hide();
dispose();
System.exit(0);
}
return super.handleEvent(e);
}

public boolean action(Event e, Object o){

if(e.target == botlimpiar){

cajanombre.setText("");
cajaedad.setText("");
cajatelefono.setText("");
checmovil.setState(false);
checdistribuido.setState(false);
checweb.setState(false);
checprogramacion.setState(false);
checservidor.setState(false);
checbd.setState(false);
textdatos.setText("");
}

if(e.target == botaceptar){
textdatos.append(cajanombre.getText() + "\n");
textdatos.append(cajaedad.getText() + "\n");
textdatos.append(cajatelefono.getText() + "\n");

if (checmovil.getState() == true){
textdatos.append("Computo movil" + "\n");
}
if (checdistribuido.getState() == true){
textdatos.append("Computo distribuido" + "\n");
}
if (checweb.getState() == true){
textdatos.append("Web" + "\n");
}
if (checprogramacion.getState() == true){
textdatos.append("Programacion" + "\n");
}
if (checservidor.getState() == true){
textdatos.append("Cliente / Servidor" + "\n");
}
if (checbd.getState() == true){
textdatos.append("Bases de Datos" + "\n");
}
}

if(e.target == botguardar){

archivo1.escribe(textdatos.getText());

}

if( e.target == botleer){
textdatos.setText("");
textdatos.setText(archivo1.read());
}

textdatos.append("\n");

return true;

}

public static void main(String arg[]){

Frame1 cuadro = new Frame1();
}
}


class Archivos{

RandomAccessFile archivo;
String texto;

Archivos(String nombre){

texto = "";

try{
archivo = new RandomAccessFile(nombre, "rw");
}catch(IOException e){
//System.out.println("Error...");
}
}

void escribe(String cadena){

try{
archivo.seek(archivo.length());
archivo.write(cadena.getBytes());
}catch(IOException e){
//System.out.println("Error al escribir.");
}
}

String read(){

texto = "";

try{
archivo.seek(0);
do{
texto = texto + archivo.readLine() + "\n";
}while(archivo.getFilePointer() < archivo.length());
}catch(IOException e){
//
}

return texto;
}
}



/*
<applet code = "Paneles.class" width = 500 height = 500>
</applet>
*/

import java.awt.*;
import java.applet.Applet;

public class Paneles extends Applet{

public void init(){

Panel panel1, panel2;
Label etiqueta1, etiqueta2;

panel1= new Panel();
panel2= new Panel();
etiqueta1 = new Label("Panel 1");
etiqueta2 = new Label("Panel 2");

panel1.setBackground(Color.blue);
panel2.setBackground(Color.red);
panel1.add(etiqueta1);
panel2.add(etiqueta2);

add(panel1);
add(panel2);
}
}



/*
<applet code="FlowDefault.class" width = 300 height = 300>
</applet>
*/

import java.awt.*;
import java.applet.Applet;

public class FlowDefault extends Applet
{
Button b1,b2,b3,b4,b5;
public void init(){
setLayout(new BorderLayout());
b1=new Button("b1");
b2=new Button("b2");
b3=new Button("b3");
b4=new Button("b4");
b5=new Button("b5");
add("South",b1);
add("North",b2);
add("East",b3);
add("Center",b4);
add("West",b5);
}
}