0% found this document useful (0 votes)
91 views10 pages

Grupo 24 PDF

The document contains 5 applets that demonstrate interaction between humans and computers using graphical components in Java. The applets create labels, text fields, buttons, lists and panels to build interfaces for login screens, registration forms, puzzles, and a calculator. Methods are used to initialize components, handle events, and generate randomized outputs. The applets showcase the use of classes, objects, layouts and events to create interactive programs.

Uploaded by

bolin3001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
91 views10 pages

Grupo 24 PDF

The document contains 5 applets that demonstrate interaction between humans and computers using graphical components in Java. The applets create labels, text fields, buttons, lists and panels to build interfaces for login screens, registration forms, puzzles, and a calculator. Methods are used to initialize components, handle events, and generate randomized outputs. The applets showcase the use of classes, objects, layouts and events to create interactive programs.

Uploaded by

bolin3001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Universidad Autónoma Gabriel René Moreno

Facultad de Ingeniería y Ciencias de la


Computación y Telecomunicaciones

INTERACCION HOMBRE - COMPUTADOR


CONTENIDO: APPLETS CON INTERACCIÓNES

Nro. Nombre
1 Acebo Chumacero Magdy Daniela
2 Lozada Fuentes Edson Dennis
3 Miranda Melendres Paul Jesus
4 Mercado Oudalova Erick Denis
5 Saucedo Acarapi Josué Harim Silver
6 Uscamaita Poma Tatiana ELena

Disponible desde: lunes, 28 de enero de 2020, 18:50


Fecha de entrega: lunes, 28 de enero de 2020, 20:00
Días de retraso: 0
Santa Cruz – Bolivia
1. Applet Login
package Componentes;

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

public class Ejercicio1 extends Applet {


public Label login, pass;
public TextField txtlogin, txtpass;
public Button registrar;

@Override
public void init() {
this.login = new Label("LOGIN");
this.login.setBackground(Color.BLACK);
this.login.setFont(new Font("TimesRoman", Font.BOLD,
15));
this.login.setForeground(Color.WHITE);
this.pass = new Label("PASSWORD");
this.pass.setBackground(Color.BLACK);
this.pass.setFont(new Font("TimesRoman", Font.BOLD,
15));
this.pass.setForeground(Color.WHITE);
this.txtlogin = new TextField(50);
this.txtpass = new TextField(50);
this.registrar = new Button("REGISTRAR");

this.add(this.login);
this.add(this.txtlogin);
this.add(this.pass);
this.add(this.txtpass);
this.add(this.registrar);
this.setBackground(Color.BLACK);
}
}
2. Applet Registrar en lista.

package Componentes;

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

public class Ejercicio2 extends Applet {


private List lista;
private Label lab;
private TextField txt;
private Button boton;

@Override
public void init() {
this.lab = new Label("ALGO");
this.lab.setBackground(Color.BLACK);
this.lab.setFont(new Font("TimesRoman", Font.BOLD,
20));
this.lab.setForeground(Color.WHITE);
this.lista = new List(10,true);
this.lista.setFont(new Font("TimesRoman", Font.BOLD,
20));
this.boton = new Button("REGISTRAR");
this.txt = new TextField(50);
this.boton.setFont(new Font("TimesRoman", Font.BOLD,
20));
this.add(this.lab);
this.add(this.txt);
this.add(this.lista);
this.add(this.boton);
this.setBackground(Color.BLACK);
}
@Override
public boolean action(Event evt, Object obj) {
if (evt.target == this.boton) {
String cad = this.txt.getText();
this.lista.add(cad);
}
return true;
}
}
3. Applet Copiar Lista
package admcomponentes;

import java.applet.Applet;
import java.awt.Button;
import java.awt.Color;
import java.awt.Event;
import java.awt.Font;
import java.awt.List;

public class CopiaLista extends Applet {


private List l1;
private List l2;
private Button b1;

@Override
public void init() {
this.l1 = new List(10,true);
this.l1.setBackground(Color.BLACK);
this.l1.setFont(new Font("TimesRoman", Font.BOLD,
20));
this.l1.setForeground(Color.CYAN);
this.l2 = new List(10,false);
this.l2.setBackground(Color.BLACK);
this.l2.setFont(new Font("TimesRoman", Font.BOLD,
20));
this.l2.setForeground(Color.CYAN);
this.b1 = new Button("COPIAR");
this.l1.add("uno");
this.l1.add("dos");
this.l1.add("tres");
this.add(this.l1);
this.add(this.b1);
this.add(this.l2);

this.setBackground(Color.BLACK);
}

@Override
public boolean action(Event evt, Object obj) {
if (evt.target == this.b1) {
String a[] = this.l1.getSelectedItems();
for (String ele : a) {
this.l2.add(ele);
}
}
return true;
}
}

4. Applet Copiar Lista


package admcomponentes;

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

public class JuegoPuzzle extends Applet {


private Puzzle p1, p2;

@Override
public void init() {
this.p1 = new Puzzle(3, 3);
this.p2 = new Puzzle(3, 3);
this.p1.setLayout(new GridLayout(3, 3));
this.p2.setLayout(new GridLayout(3, 3));

this.p1.generarFinal();
this.p2.generarInicial();

this.add(this.p1);
this.add(this.p2);

this.setBackground(Color.BLACK);
}
}
package admcomponentes;

import java.awt.Button;
import java.awt.Panel;

public class Puzzle extends Panel{


private int n, m;

public Puzzle() {
}

public Puzzle(int n, int m) {


this.n = n;
this.m = m;
}

public void generarFinal() {


for (int i = 0; i < this.n * this.m - 1; i++) {
this.add(new Button(Integer.toString(i)));
}
this.add(new Button("0"));
}

public void generarInicial() {


for (int i = this.n * this.m - 1; i >= 0; i--) {
this.add(new Button(Integer.toString(i)));
}
}
}

5.
5. Applet Calculadora
package componentes;

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

public class calc extends Applet {

private Label la;


private TextField txt;
private calcBotones c;

@Override
public void init() {
this.la = new Label("CALCULADORA");
this.la.setForeground(Color.BLACK);
this.la.setFont(new Font("sansserif", 1, 50));

this.txt = new TextField(50);


this.txt.setForeground(Color.BLACK);
this.txt.setFont(new Font("sansserif", 1, 30));

this.c = new calcBotones(4, 5);


this.c.setLayout(new GridLayout(4, 5));
this.c.cargar();

this.add(this.la);
this.add(this.txt);
this.add(c);

}
}

package componentes;

import java.awt.*;

public class calcBotones extends Panel{

private int n,m;

public calcBotones(int n,int m){


this.n = n;
this.m = m;
}

public void cargar(){


this.add(llenarCaracteristicas("%"));
this.add(llenarCaracteristicas("7"));
this.add(llenarCaracteristicas("8"));
this.add(llenarCaracteristicas("9"));
this.add(llenarCaracteristicas("/"));
this.add(llenarCaracteristicas("√"));
this.add(llenarCaracteristicas("4"));
this.add(llenarCaracteristicas("5"));
this.add(llenarCaracteristicas("6"));
this.add(llenarCaracteristicas("x"));
this.add(llenarCaracteristicas("C"));
this.add(llenarCaracteristicas("1"));
this.add(llenarCaracteristicas("2"));
this.add(llenarCaracteristicas("3"));
this.add(llenarCaracteristicas("-"));
this.add(llenarCaracteristicas("AC"));
this.add(llenarCaracteristicas("0"));
this.add(llenarCaracteristicas("."));
this.add(llenarCaracteristicas("="));
this.add(llenarCaracteristicas("+"));
}

public Button llenarCaracteristicas(String ch) {


Button boton = new Button();
boton.setBackground(Color.cyan);
boton.setForeground(Color.black);
boton.setFont(new Font("sansserif", 5, 50));
boton.setLabel(ch);
return boton;
}
}
COMENTARIOS
Se hizo el uso de los componente gráficos en
mención, también se usaron clase y métodos
auxiliares para complementar los gráficos, se
pudo evidenciar la jerarquía de clases.

You might also like