Documentos de Académico
Documentos de Profesional
Documentos de Cultura
UNIDAD 3. Acceso A Datos Carranza
UNIDAD 3. Acceso A Datos Carranza
System.out.println("Hola mundo");
System.out.println("Hola mundo");
int numero_uno = 5;
int numero_dos = 2;
int resultado = 0;
}
public class Operaciones{
int numero_uno = 4;
int numero_dos = 4;
int resultado = 0;
int matematicas = 5;
int biologia = 5;
int quimica = 5;
int promedio = 0;
int operacion = 1;
int num_uno = 8;
int num_dos = 4;
int resultado = 0;
if(operacion == 1){
} else {
import java.util.Scanner;
nombre = in.nextLine();
System.out.println("Dame el primer valor para tu suma: ");
numUno = in.nextInt();
numDos = in.nextInt();
System.out.println(" Hola " + nombre + " el resultado de tu suma es: " + resultado);
import java.util.Scanner;
System.out.println("*********************************************************
********************");
System.out.println("");
System.out.println("");
nombre = entrada.nextLine();
System.out.println("");
antiguedad = entrada.nextInt();
System.out.println("");
clave = entrada.nextInt();
System.out.println("");
if(clave == 1){
if(antiguedad == 1){
if(antiguedad == 1){
if(antiguedad == 1){
} else {
}
Curso de Java video 11-20 Actividad 7
int parametro = 2;
switch(parametro){
break;
break;
break;
break;
break;
}
}
int i = 1;
i+=2;
}
}
int i = 1000;
do{
i -=200;
int i = 0;
System.out.print( i + ",");
} else {
System.out.print(i);
i = 1;
System.out.println("");
System.out.print( i + ",");
} else {
System.out.print(i);
i ++;
i = 1;
System.out.println("");
System.out.print( i + ",");
} else {
System.out.print(i);
i ++;
int i = 1, j = 99;
System.out.print(i + ",");
System.out.print(j + ",");
} else {
System.out.print(i + ",");
System.out.print(j);
j--;
System.out.println("");
i = 1;
j = 99;
System.out.print(i + ",");
System.out.print(j + ",");
} else {
System.out.print(i + ",");
System.out.print(j);
i++;
j--;
System.out.println("");
i = 1;
j = 99;
System.out.println("Serie con do-while: ");
do{
System.out.print(i + ",");
System.out.print(j + ",");
} else {
System.out.print(i + ",");
System.out.print(j);
i++;
j--;
int i = 0, a = 0, b = 1, c = 0;
System.out.println("Serie con for: ");
System.out.print(a + ",");
c = a + b;
a = b;
b = c;
} else {
System.out.print(a);
System.out.println("");
i = 0;
b = 1;
a = 0;
c = 0;
System.out.print(a + ",");
c = a + b;
a = b;
b = c;
} else {
System.out.print(a);
i++;
System.out.println("");
i = 0;
b = 1;
a = 0;
c = 0;
do{
System.out.print(a + ",");
c = a + b;
a = b;
b = c;
} else {
System.out.print(a);
i++;
import java.util.Scanner;
nombre_uno = entrada.nextLine();
if(nombre_uno.equalsIgnoreCase(nombre_dos)){
} else{
import java.util.Scanner;
usuario = entrada.nextLine();
System.out.print(" Ingresa tu contrasena: ");
password = entrada.nextLine();
} else {
import java.util.Scanner;
cadena_original = in.nextLine();
num_caracteres = cadena_original.length();
desde = in.nextInt();
hasta = in.nextInt();
}
public class Vectores{
numeros [0] = 5;
numeros [2] = 8;
}
import java.util.Scanner;
int longitud = 0;
longitud = entrada.nextInt();
numeros[i] = entrada.nextInt();
}
Curso de Java video 21-30 Actividad 8
}
import java.util.Scanner;
filas = entrada.nextInt();
columnas = entrada.nextInt();
numeros[ j ] [ i ] = contador;
contador++;
System.out.println("");
}
import javax.swing.*;
public Formulario(){
setLayout(null);
label1.setBounds(10,20,200,300);
add(label1);
formulario1.setBounds(0,0,400,300);
formulario1.setVisible(true);
formulario1.setLocationRelativeTo(null);
}
import javax.swing.*;
public Formularios(){
setLayout(null);
formulario1.setBounds(0,0,400,550);
formulario1.setVisible(true);
formulario1.setLocationRelativeTo(null);
formulario1.setResizable(false);
}
import javax.swing.*;
public Formulario(){
setLayout(null);
label1.setBounds(10,20,300,30);
add(label1);
label2.setBounds(10,100,100,30);
add(label2);
formulario1.setBounds(0,0,300,200);
formulario1.setResizable(false);
formulario1.setVisible(true);
formulario1.setLocationRelativeTo(null);
import javax.swing.*;
import java.awt.event.*;
JButton boton1;
public Formulario(){
setLayout(null);
boton1.setBounds(300,250,100,30);
add(boton1);
boton1.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == boton1){
System.exit(0);
formulario1.setBounds(0,0,450,350);
formulario1.setVisible(true);
formulario1.setResizable(false);
formulario1.setLocationRelativeTo(null);
import javax.swing.*;
import java.awt.event.*;
public class Formulario extends JFrame implements ActionListener{
public Formulario(){
setLayout(null);
boton1.setBounds(10,100,90,30);
add(boton1);
boton1.addActionListener(this);
boton2.setBounds(110,100,90,30);
add(boton2);
boton2.addActionListener(this);
boton3.setBounds(210,100,90,30);
add(boton3);
boton3.addActionListener(this);
label1.setBounds(10,10,300,30);
add(label1);
if(e.getSource() == boton1){
if(e.getSource() == boton2){
if(e.getSource() == boton3){
formulario1.setBounds(0,0,350,200);
formulario1.setVisible(true);
formulario1.setResizable(false);
formulario1.setLocationRelativeTo(null);
}
}
import javax.swing.*;
import java.awt.event.*;
public Formulario(){
setLayout(null);
label1.setBounds(10,10,100,30);
add(label1);
textfield1.setBounds(120,17,150,20);
add(textfield1);
boton1 = new JButton("Aceptar");
boton1.setBounds(10,80,100,30);
add(boton1);
boton1.addActionListener(this);
if(e.getSource() == boton1){
setTitle(texto);
formulario1.setBounds(0,0,300,150);
formulario1.setVisible(true);
formulario1.setResizable(false);
formulario1.setLocationRelativeTo(null);
}
import javax.swing.*;
public Formulario(){
setLayout(null);
textfield1.setBounds(10,10,200,30);
add(textfield1);
textarea1.setBounds(10,50,400,300);
add(textarea1);
formulario1.setBounds(0,0,540,400);
formulario1.setVisible(true);
formulario1.setResizable(false);
formulario1.setLocationRelativeTo(null);
}
Curso de java video 31-40 Actividad 9
import javax.swing.*;
public Formulario(){
setLayout(null);
textfield1.setBounds(10,10,200,30);
add(textfield1);
scrollpane1.setBounds(10,50,400,300);
add(scrollpane1);
formulario1.setVisible(true);
formulario1.setResizable(false);
formulario1.setLocationRelativeTo(null);
import javax.swing.*;
import java.awt.event.*;
public Formulario(){
setLayout(null);
textfield1 = new JTextField();
textfield1.setBounds(10,10,200,30);
add(textfield1);
boton1.setBounds(250,10,100,30);
add(boton1);
boton1.addActionListener(this);
scrollpane1.setBounds(10,50,400,300);
add(scrollpane1);
if(e.getSource() == boton1){
textarea1.setText(texto);
textfield1.setText("");
}
public static void main(String args[]){
formulario1.setBounds(0,0,540,400);
formulario1.setVisible(true);
formulario1.setResizable(false);
formulario1.setLocationRelativeTo(null);
import javax.swing.*;
import java.awt.event.*;
public Formulario(){
setLayout(null);
add(label1);
label2.setBounds(50,35,100,30);
add(label2);
label3.setBounds(120,80,100,30);
add(label3);
textfield1.setBounds(120,10,150,20);
add(textfield1);
textfield2.setBounds(120,40,150,20);
add(textfield2);
boton1.setBounds(10,80,100,30);
add(boton1);
boton1.addActionListener(this);
}
if(e.getSource() == boton1){
valor1 = Integer.parseInt(textfield1.getText());
valor2 = Integer.parseInt(textfield2.getText());
formulario1.setBounds(0,0,300,150);
formulario1.setVisible(true);
formulario1.setResizable(false);
formulario1.setLocationRelativeTo(null);
}
import javax.swing.*;
import java.awt.event.*;
public Formulario(){
setLayout(null);
combo1.setBounds(10,10,80,20);
add(combo1);
combo1.addItem("rojo");
combo1.addItem("verde");
combo1.addItem("azul");
combo1.addItem("morado");
combo1.addItem("negro");
combo1.addItemListener(this);
if(e.getSource() == combo1){
String seleccion = combo1.getSelectedItem().toString();
setTitle(seleccion);
formulario1.setBounds(10,10,200,150);
formulario1.setVisible(true);
formulario1.setResizable(false);
formulario1.setLocationRelativeTo(null);
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public Formulario(){
setLayout(null);
label1.setBounds(10,10,100,10);
add(label1);
combo1.setBounds(120,10,50,30);
combo1.addItem(String.valueOf(i) );
add(combo1);
setLayout(null);
label2.setBounds(10,50,100,10);
add(label2);
combo2.setBounds(120,50,50,30);
combo2.addItem(String.valueOf(i) );
add(combo2);
setLayout(null);
label3.setBounds(10,90,100,10);
add(label3);
combo3.setBounds(120,90,50,30);
combo3.addItem(String.valueOf(i) );
add(combo3);
boton1 = new JButton("Fijar color");
boton1.setBounds(10,130,100,30);
add(boton1);
boton1.addActionListener(this);
if(e.getSource() == boton1){
boton1.setBackground(color1);
formulario1.setBounds(0,0,190,220);
formulario1.setVisible(true);
formulario1.setResizable(false);
formulario1.setLocationRelativeTo(null);
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public Formulario(){
setLayout(null);
setJMenuBar(menubar);
menubar.add(menu1);
menuitem1.addActionListener(this);
menu1.add(menuitem1);
menuitem2.addActionListener(this);
menu1.add(menuitem2);
menuitem3.addActionListener(this);
menu1.add(menuitem3);
fondo.setBackground(new Color(255,0,0) );
if(e.getSource() == menuitem2){
fondo.setBackground(new Color(0,255,0) );
if(e.getSource() == menuitem3){
fondo.setBackground(new Color(0,0,255) );
formulario1.setBounds(0,0,400,300);
formulario1.setVisible(true);
formulario1.setLocationRelativeTo(null);
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public Formulario(){
setLayout(null);
setJMenuBar (menubar);
menubar.add(menu1);
menu1.add(menu2);
menu1.add(menu3);
menuitem1 = new JMenuItem("300*200");
menu2.add(menuitem1);
menuitem1.addActionListener(this);
menu2.add(menuitem2);
menuitem2.addActionListener(this);
menu3.add(menuitem3);
menuitem3.addActionListener(this);
menu3.add(menuitem4);
menuitem4.addActionListener(this);
if(e.getSource() == menuitem1){
setSize(300,200);
if(e.getSource() == menuitem2){
setSize(640,480);
if(e.getSource() == menuitem3){
getContentPane().setBackground(new Color(255,0,0));
if(e.getSource() == menuitem4){
getContentPane().setBackground(new Color(0,255,0));
formulario1.setBounds(0,0,300,200);
formulario1.setVisible(true);
formulario1.setResizable(false);
formulario1.setLocationRelativeTo(null);
}
import javax.swing.*;
import javax.swing.event.*;
public Formulario(){
setLayout(null);
check1.setBounds(10,10,150,30);
check1.addChangeListener(this);
add(check1);
check2.setBounds(10,50,150,30);
check2.addChangeListener(this);
add(check2);
check3.setBounds(10,90,150,30);
check3.addChangeListener(this);
add(check3);
}
String cad="";
if(check1.isSelected() == true){
if(check2.isSelected() == true){
if(check3.isSelected() == true){
setTitle(cad);
formulario1.setBounds(0,0,350,200);
formulario1.setVisible(true);
formulario1.setResizable(false);
formulario1.setLocationRelativeTo(null);
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
public Formulario(){
setLayout(null);
label1.setBounds(10,10,400,30);
add(label1);
check1 = new JCheckBox("Acepto");
check1.setBounds(10,50,100,30);
check1.addChangeListener(this);
add(check1);
boton1.setBounds(10,100,100,30);
add(boton1);
boton1.addActionListener(this);
boton1.setEnabled(false);
if(check1.isSelected() == true){
boton1.setEnabled(true);
} else{
boton1.setEnabled(false);
if(e.getSource() == boton1){
System.exit(0);
formulario1.setBounds(0,0,350,200);
formulario1.setVisible(true);
formulario1.setResizable(false);
formulario1.setLocationRelativeTo(null);
}
import javax.swing.*;
import javax.swing.event.*;
public Formulario(){
setLayout(null);
bg = new ButtonGroup();
radio1.setBounds(10,20,100,30);
radio1.addChangeListener(this);
add(radio1);
bg.add(radio1);
radio2.setBounds(10,70,100,30);
radio2.addChangeListener(this);
add(radio2);
bg.add(radio2);
radio3= new JRadioButton("1024*768");
radio3.setBounds(10,120,100,30);
radio3.addChangeListener(this);
add(radio3);
bg.add(radio3);
if(radio1.isSelected() ){
setSize(640,480);
if(radio2.isSelected()){
setSize(800,600);
if(radio3.isSelected()){
setSize(1024,768);
formulario1.setVisible(true);
formulario1.setResizable(false);
}
Curso de java video 41-48 Actividad 10
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public Bienvenida(){
setLayout(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setTitle("Bienvenida");
getContentPane().setBackground(new Color(255,0,0));
setIconImage(new
ImageIcon(getClass().getResource("images/icon.png")).getImage());
label1.setBounds(25,15,300,150);
add(label1);
label2.setBounds(35,135,300,30);
label2.setForeground(new Color(255,255,255));
add(label2);
label3.setBounds(45,212,200,30);
label3.setForeground(new Color(255,255,255));
add(label3);
label4.setBounds(85,375,300,30);
label4.setForeground(new Color(255,255,255));
add(label4);
textfield1.setBackground(new Color(224,224,224));
textfield1.setForeground(new Color(255,0,0));
add(textfield1);
boton1.setBounds(125,280,100,30);
boton1.setBackground(new Color(255,255,255));
boton1.setForeground(new Color(255,0,0));
boton1.addActionListener(this);
add( boton1);
if(e.getSource() == boton1){
texto = textfield1.getText().trim();
if(texto.equals("")){
} else{
ventanalicencia.setBounds(0,0,600,360);
ventanalicencia.setVisible(true);
ventanalicencia.setResizable(false);
ventanalicencia.setLocationRelativeTo(null);
this.setVisible(false);
ventanabienvenida.setBounds(0,0,350,450);
ventanabienvenida.setVisible(true);
ventanabienvenida.setResizable(false);
ventanabienvenida.setLocationRelativeTo(null);
}
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
public Licencia(){
setLayout(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setTitle("Licencia de uso");
setIconImage(new ImageIcon(getClass().getResource("images/icon.png")).getImage());
nombre = ventanaBienvenida.texto;
label1 = new JLabel("Terminos y condicones");
label1.setBounds(215,5,200,30);
add(label1);
textarea1.setEditable(false);
scrollpane1.setBounds(10,40,575,200);
add(scrollpane1);
check1.setBounds(10,250,300,30);
check1.addChangeListener(this);
add(check1);
boton1.setBounds(10,290,100,30);
boton1.addActionListener(this);
boton1.setEnabled(false);
add(boton1);
boton2.setBounds(120,290,100,30);
boton2.addActionListener(this);
boton2.setEnabled(true);
add(boton2);
label2.setBounds(315,135,300,300);
add(label2);
if(check1.isSelected() == true){
boton1.setEnabled(true);
boton2.setEnabled(false);
} else{
boton1.setEnabled(false);
boton2.setEnabled(true);
}
if(e.getSource() == boton1){
ventanaPrincipal.setBounds(0,0,640,535);
ventanaPrincipal.setVisible(true);
ventanaPrincipal.setResizable(false);
ventanaPrincipal.setLocationRelativeTo(null);
this.setVisible(false);
ventanabienvenida.setBounds(0,0,350,450);
ventanabienvenida.setVisible(true);
ventanabienvenida.setResizable(false);
ventanabienvenida.setLocationRelativeTo(null);
this.setVisible(false);
}
public static void main(String args[]){
ventanalicencia.setBounds(0,0,600,360);
ventanalicencia.setVisible(true);
ventanalicencia.setResizable(false);
ventanalicencia.setLocationRelativeTo(null);
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
private JMenuItem
miCalculo,miRojo,miNegro,miMorado,miElCreador,miSalir,miNuevo;
private JLabel
labelLogo,labelBienvenido,labelTitle,labelNombre,labelAPaterno,labelAMaterno,
labelDepartamento,labelAntiguedad,labelResultado,labelfooter;
public Principal(){
setLayout(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setTitle("Pantalla principal");
getContentPane().setBackground(new Color(255,0,0));
setIconImage(new ImageIcon(getClass().getResource("images/icon.png")).getImage());
nombreAdministrador = ventanaBienvenida.texto;
mb = new JMenuBar();
setJMenuBar(mb);
mb.add(menuOpciones);
mb.add(menuAcercaDe);
menuOpciones.add(menuColorFondo);
menuCalcular.add(miCalculo);
miCalculo.addActionListener(this);
menuColorFondo.add(miRojo);
miRojo.addActionListener(this);
menuColorFondo.add(miNegro);
miNegro.addActionListener(this);
menuColorFondo.add(miMorado);
miMorado.addActionListener(this);
menuOpciones.add(miNuevo);
miNuevo.addActionListener(this);
miElCreador = new JMenuItem("El creador");
menuAcercaDe.add(miElCreador);
miElCreador.addActionListener(this);
menuOpciones.add(miSalir);
miSalir.addActionListener(this);
labelLogo.setBounds(5,5,250,100);
add(labelLogo);
labelBienvenido.setBounds(280,30,300,50);
labelTitle.setBounds(45,140,900,25);
add(labelTitle);
labelNombre.setBounds(25,188,180,25);
add(labelNombre);
txtNombreTrabajador.setBounds(25,213,150,25);
add(txtNombreTrabajador);
labelAPaterno = new JLabel("Apellido Paterno:");
labelAPaterno.setBounds(25,248,180,25);
add(labelAPaterno);
txtAPaternoTrabajador.setBounds(25,273,150,25);
add(txtAPaternoTrabajador);
labelAMaterno.setBounds(25,308,180,25);
add(labelAMaterno);
txtAMaternoTrabajador.setBounds(25,334,150,25);
txtAMaternoTrabajador.setBackground(new java.awt.Color(224, 224, 224));
add(txtAMaternoTrabajador);
labelDepartamento.setBounds(220,188,180,25);
add(labelDepartamento);
comboDepartamento.setBounds(220,213,220,25);
add(comboDepartamento);
comboDepartamento.addItem("");
comboDepartamento.addItem("Atencion al Cliente");
comboDepartamento.addItem("Departamento de Logística");
comboDepartamento.addItem("Departamento de Gerencia");
add(labelAntiguedad);
comboAntiguedad.setBounds(220,273,220,25);
add(comboAntiguedad);
comboAntiguedad.addItem("");
labelResultado.setBounds(220,307,180,25);
add(labelResultado);
scrollpane1.setBounds(220,333,385,90);
add(scrollpane1);
labelfooter.setBounds(135,445,500,30);
add(labelfooter);
if(e.getSource() == miCalculo){
String AP = txtAPaternoTrabajador.getText();
String AM = txtAMaternoTrabajador.getText();
Departamento.equals("") || Antiguedad.equals("")){
} else{
if(Departamento.equals("Atención al Cliente")){
if(Departamento.equals("Departamento de Logistica")){
if(Departamento.equals("Departamento de Gerencia")){
if(e.getSource() == miRojo){
getContentPane().setBackground(new Color(255,0,0));
if(e.getSource() == miNegro){
getContentPane().setBackground(new Color(0,0,0));
if(e.getSource() == miMorado){
getContentPane().setBackground(new Color(51,0,51));
if(e.getSource() == miNuevo){
txtNombreTrabajador.setText("");
txtAPaternoTrabajador.setText("");
txtAMaternoTrabajador.setText("");
comboDepartamento.setSelectedIndex(0);
comboAntiguedad.setSelectedIndex(0);
if(e.getSource() == miSalir){
ventanabienvenida.setBounds(0,0,350,450);
ventanabienvenida.setVisible(true);
ventanabienvenida.setResizable(false);
ventanabienvenida.setLocationRelativeTo(null);
this.setVisible(false);
if(e.getSource() == miElCreador){
JOptionPane.showMessageDialog(null, "Desarrollado por Carranza Guerra
Roberto Carlos");
ventanaPrincipal.setBounds(0,0,640,535);
ventanaPrincipal.setVisible(true);
ventanaPrincipal.setResizable(false);
ventanaPrincipal.setLocationRelativeTo(null);