Вы находитесь на странице: 1из 17

PROGRAMAS

AGENDA package agenda; public class Main { public static void main(String[] args) { // TODO code application logic here persona p1; p1=new persona(); p1.nombre="Israel"; p1.apellido="Alcantara"; p1.direccion="santa maria"; p1.edad="16"; p1.correo="israel_16@hoimail.com"; p1.telefono="7120249647"; persona p2; p2=new persona(); p2.nombre="Alejandro"; p2.apellido="Bernal"; p2.direccion="santiago"; p2.edad="16"; p2.correo="alejandro_16@hoimail.com" ; p2.telefono="7120236647"; persona p3; p3=new persona(); p3.nombre="Adan"; p3.apellido="cardenas"; p3.direccion="santiago"; p3.edad="17"; p3.correo="adan_16@hoimail.com"; p3.telefono="7121024964"; persona p4; p4=new persona(); p4.nombre="jonatan"; p4.apellido="eslaba"; p4.direccion="santiago"; p4.edad="16"; p4.correo="jonatan_12@hoimail.com"; p4.telefono="7122459638"; persona p5; p5=new persona(); p5.nombre="yoselin"; p5.apellido="cortez"; p5.direccion="sanjuan"; p5.edad="15"; p5.correo="yoselin_yos@hoimail.com"; p5.telefono="7122459687"; persona p6; p6=new persona(); p6.nombre="valentin"; p6.apellido="fuentes"; p6.direccion="santiago"; p6.edad="16"; p6.correo="valentin_vale@hoimail.com "; p6.telefono="7129573691"; persona p7; p7=new persona(); p7.nombre="visente"; p7.apellido="garcia"; p7.direccion="santa maria"; p7.edad="16"; p7.correo="visente_96@hoimail.com"; p7.telefono="7129637584"; persona p8; p8=new persona(); p8.nombre="dariem"; p8.apellido="davila";

p8.direccion="sanjuan"; p8.edad="16"; p8.correo="dari_davila@hoimail.com"; p8.telefono="7129687231"; persona p9; p9=new persona(); p9.nombre="arturo"; p9.apellido="hernandes"; p9.direccion="santa maria"; p9.edad="16"; p9.correo="arturo@hoimail.com"; p9.telefono="7129005431"; persona p10; p10=new persona(); p10.nombre="carmen"; p10.apellido="lopes"; p10.direccion="santiago"; p10.edad="16"; p10.correo="car@hoimail.com"; p10.telefono="7123059820"; persona p11; p11=new persona(); p11.nombre="maria guadalupe"; p11.apellido="miguel"; p11.direccion="santa maria"; p11.edad="17"; p11.correo="chuvaslupis@live.com"; p11.telefono="7121515608"; persona p12; p12=new persona(); p12.nombre="yeimi itzel"; p12.apellido="nava"; p12.direccion="sanjuan"; p12.edad="16"; p12.correo="yeiitzel@hoimail.com"; p12.telefono="7127539581";

persona p13; p13=new persona(); p13.nombre="yovani"; p13.apellido="casimiro"; p13.direccion="santiago"; p13.edad="16"; p13.correo="yavas_89@hoimail.com"; p13.telefono="7121439785"; persona p14; p14=new persona(); p14.nombre="yesica"; p14.apellido="segundo"; p14.direccion="sanjuan"; p14.edad="16"; p14.correo="yesi@hoimail.com"; p14.telefono="7127264381"; persona p15; p15=new persona(); p15.nombre="monica"; p15.apellido="valdes"; p15.direccion="santa maria"; p15.edad="16"; p15.correo="prinsesita@hoimail.com"; p15.telefono="7121427596"; p1.mostrarnombre(); p2.mostrarnombre(); p3.mostrarnombre(); p4.mostrarnombre(); p5.mostrarnombre(); p6.mostrarnombre(); p7.mostrarnombre(); p8.mostrarnombre(); p9.mostrarnombre(); p10.mostrarnombre(); p11.mostrarnombre(); p12.mostrarnombre(); p13.mostrarnombre(); p14.mostrarnombre(); p15.mostrarnombre();

System.out.println(persona.total); } } package agenda; public class persona { public static int total; String nombre; String apellido; String direccion; String edad; String correo; String telefono;

public persona(){ persona.total ++; } public void mostrarnombre() { System.out.println(nombre+" "+apellido+" "+direccion+" "+edad+" "+correo+" "+telefono); } }

CLASES package clases; public class Main { public static void main(String[] args) { // TODO code application logic here Pelota p; p=new Pelota(500,500); float x=p.obtenerRadio(); p.patearPelota(); p.atraparPelota(); } } package clases; public class Pelota { //variables nativas de la clase float radio; float peso; //constructores public Pelota(){ radio=100; peso=250; } public Pelota(float radio,float peso){ this.radio=radio; //con el this hase referencia a la variable nativa this.peso=peso; } //metodo:es una funcion que ejecuta ciertas lineas de codigo para lograr algo public float obtenerRadio(){ return this.radio; } public float obtenerPeso(){ return this.peso; } public void patearPelota(){ System.out.println("haz pateado la pelota"); }

public void atraparPelota(){ System.out.println("haz artapado la pelota"); } }

//metodos public void encender(){ this.encendido=true; System.out.println("el carro esta ensendido"); }

CLASEE2 package clases; public class Main { public static void main(String[] args) { Carro c; c=new Carro(); c.encender(); c.apagar(); } } package clases; public class Carro { //variables double peso; double altura; double ancho; double largo; int numPuertas; boolean encendido=true; boolean apagado=false; String modelo; //constructor public Carro(){ this.peso=1000; this.altura=1.90; this.ancho=4; }

public void apagar(){ this.apagado=false; System.out.println("el caro esta apagado"); } }

DATOS PERSONALES package datospersonales; public class Main { public static void main(String[] args) { // TODO code application logic here Ventana v; v=new Ventana(); // v.setX(450); // v.setY(200); } } package datospersonales; import java.awt.event.ActionEvent; import java.awt.Color; public class Ventana extends javax.swing.JFrame { private int x,y ; public Ventana(){ //codigo para fondo de pantalla javax.swing.JPanel fondo; fondo=new javax.swing.JPanel(); fondo.setSize(900, 800); java.awt.Color c4; c4=new java.awt.Color(100, 50, 100); fondo.setBackground(c4); //codigo para crear un boton javax.swing.JButton botoncito; botoncito=new javax.swing.JButton("Mostrar Datos"); botoncito.setLocation(550,150); botoncito.setSize(150,50); this.add(botoncito); botoncito.setBackground(Color.YELLOW ); //codigo para crear cajas de texto final javax.swing.JTextField caja; caja=new javax.swing.JTextField(); caja.setLocation(150, 70); caja.setSize(300, 30);

final javax.swing.JTextField caja1; caja1=new javax.swing.JTextField(); caja1.setLocation(150, 170); caja1.setSize(300, 30); final javax.swing.JTextField caja2; caja2=new javax.swing.JTextField(); caja2.setLocation(150, 270); caja2.setSize(300, 30); final javax.swing.JTextField caja3; caja3=new javax.swing.JTextField(); caja3.setLocation(150, 370); caja3.setSize(300, 30); //codigo para crear una etiqueta javax.swing.JLabel etiqueta; etiqueta=new javax.swing.JLabel("DATOS PERSONALES"); etiqueta.setLocation(150,10); etiqueta.setSize(300,50); java.awt.Font h; h=new java.awt.Font("Chiller",1,20); etiqueta.setFont(h); etiqueta.setForeground(Color.red);

javax.swing.JLabel etiqueta1; etiqueta1=new javax.swing.JLabel("Nombre"); etiqueta1.setLocation(50,50); etiqueta1.setSize(100,60); java.awt.Font s; s=new java.awt.Font("Chiller",1,20); etiqueta1.setFont(s); etiqueta1.setForeground(Color.red); javax.swing.JLabel etiqueta2;

etiqueta2=new javax.swing.JLabel("Direccion"); etiqueta2.setLocation(50,150); etiqueta2.setSize(100,60); java.awt.Font M; M=new java.awt.Font("Chiller",1,20); etiqueta2.setFont(M); etiqueta2.setForeground(Color.red); javax.swing.JLabel etiqueta3; etiqueta3=new javax.swing.JLabel("Edad"); etiqueta3.setLocation(50,250); etiqueta3.setSize(100,60); java.awt.Font f; f=new java.awt.Font("Chiller",1,20); etiqueta3.setFont(f); etiqueta3.setForeground(Color.red); javax.swing.JLabel etiqueta4; etiqueta4=new javax.swing.JLabel("Correo"); etiqueta4.setLocation(50,350); etiqueta4.setSize(100,60); java.awt.Font k; k=new java.awt.Font("Chiller",1,20); etiqueta4.setFont(k); etiqueta4.setForeground(Color.red); //codigopara agregar un objeto a una ventana this.add(etiqueta); this.add(etiqueta1); this.add(etiqueta2); this.add(etiqueta3); this.add(etiqueta4); this.add(caja); this.add(caja1); this.add(caja2); this.add(caja3);

//this.add(area); this.add(botoncito); this.add(fondo);

java.awt.event.ActionListener z; z=new java.awt.event.ActionListener() { private Object area; public void actionPerformed(ActionEvent e) { area.setText(("Los datos capturados son:\n Nombre:"+caja.getText()+"\n Direccion:"+caja1.getText()+"\n Edad:"+caja2.getText()+"\n correo"+caja3.getText())); } }; botoncito.addActionListener(z); //codigo de la ventana this.setLayout(null); this.setSize(850,750); this.setVisible(true); this.setAlwaysOnTop(true); this.setTitle("Datos"); } }

DIBUJO package dibujos; public class Main { public static void main(String[] args) { Casita c; c=new Casita(); } } package dibujos; import java.awt.Color; import java.awt.event.ActionEvent; public class Casita extends javax.swing.JFrame { public Casita(){ //constructor //codigo para la ventana this.setSize(500, 500); this.setDefaultCloseOperation(2); this.setLayout(null); this.setLocation(70, 100); this.setTitle("Dibujando objetos"); //codigo para el fondo javax.swing.JPanel fondo; fondo=new javax.swing.JPanel(); fondo.setSize(900, 800); /*java.awt.Color c4; c4=new java.awt.Color(10, 50, 190);//dar color fondo.setBackground(c4);*/ fondo.setBackground(Color.PINK); this.add(fondo); //codigo para los botonos javax.swing.JButton dibujar; dibujar=new javax.swing.JButton("Dibujar una casita"); dibujar.setSize(150,50); dibujar.setLocation(50,350); java.awt.Color c3; c3=new java.awt.Color(255, 255, 255);//dar color dibujar.setBackground(c3); this.add(dibujar); //crear un evento java.awt.event.ActionListener b;

b=new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { java.awt.Graphics g; g=getGraphics(); g.drawOval(120,160,50,50); g.setColor(Color.YELLOW); g.fillOval(300, 50, 70, 70); g.setColor(Color.RED); g.drawLine(200, 50, 300, 150); g.drawLine(200, 50, 100, 150); g.drawLine(100, 150, 300, 150); g.drawLine(100, 150, 100, 300); g.drawLine(100, 300, 300, 300); g.drawLine(300, 300, 300, 150); g.setColor(Color.BLACK); g.drawLine(250, 300, 250, 250); g.drawLine(150, 250, 150, 300); g.drawLine(150, 250, 250, 250); g.setColor(Color.BLACK); g.drawRect(230, 160, 50, 50); g.setColor(Color.BLUE); g.drawRect(300, 200, 150, 102); g.setColor(Color.BLACK); g.drawRect( 350, 250, 50, 50); } }; dibujar.addActionListener(b); this.setVisible(true); } }

EVENTOS DEL MOUSE package eventosmouse; public class Main { public static void main(String[] args) { // TODO code application logic here Ventana1 v; v=new Ventana1(); Ventana2 v2; v2=new Ventana2(); //Ventana3 v; //v=new Ventana3(); } } package eventosmouse; import java.awt.event.MouseEvent; public class Ventana1 extends javax.swing.JFrame { public Ventana1(){ //codigo para la ventana this.setSize(400, 400); this.setDefaultCloseOperation(2); this.setLayout(null); this.setVisible(true); this.setLocation(70, 100); this.setTitle("EVENTOS DEL MOUSE"); java.awt.event.MouseListener m;//evento para el mouse m=new java.awt.event.MouseListener() { public void mouseClicked(MouseEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //System.out.println("aparese el ensaje para aser un clik"); int num=5,cub; cub=num*num*num;//calcula el numero al dar clik System.out.println("El cubo es:" + cub);

} public void mousePressed(MouseEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //System.out.println("aparese el mensaje de forma retardada"); java.awt.Graphics g; g=getGraphics(); g.drawOval(40, 40, 100, 40);//dibuja un ovalo } public void mouseReleased(MouseEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //System.out.println("al pasar el mouse sobre la ventana aparese el mensaje"); java.awt.Graphics g; g=getGraphics(); g.drawLine(200, 50, 300, 150); } public void mouseEntered(MouseEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //System.out.println("al pasar el mouse sobre la ventana aparese el mensaje"); java.awt.Graphics g; g=getGraphics(); g.drawArc(150, 50, 200, 50, 45, 90); } public void mouseExited(MouseEvent e) {

//throw new UnsupportedOperationException("Not supported yet."); //System.out.println("cuando quito el mouse de la ventana aparese el mensaje"); java.awt.Graphics g; g=getGraphics(); g.drawRect(50, 150, 250, 100); } }; this.addMouseListener(m); } } package eventosmouse; import java.awt.Color; import java.awt.event.ActionEvent; public class Ventana2 extends javax.swing.JFrame { public Ventana2 (){ //codigo para la ventana this.setSize(500, 500); this.setDefaultCloseOperation(2); this.setLayout(null); this.setLocation(70, 100); this.setTitle("EVENTOS DEL MOUSE"); //etiqueta del mouse javax.swing.JLabel etiqueta; etiqueta=new javax.swing.JLabel("**EVENTOS DE MOUSE**"); etiqueta.setLocation(50,50); etiqueta.setSize(300,50); java.awt.Font h; h=new java.awt.Font("Chiller",1,20); etiqueta.setFont(h); etiqueta.setForeground(Color.YELLOW); this.add(etiqueta); //codigo para el fondo javax.swing.JPanel fondo;

fondo=new javax.swing.JPanel(); fondo.setSize(900, 800); java.awt.Color c4; c4=new java.awt.Color(100, 50, 100); fondo.setBackground(c4); this.add(fondo); //botones cambiar color final javax.swing.JButton boton1; boton1=new javax.swing.JButton(); boton1.setLocation(50,150); boton1.setSize(150,50); boton1.setBackground(Color.GREEN); this.add(boton1); //////////7 java.awt.event.ActionListener c; c=new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { if(boton1.getBackground()==Color.GREE N){ boton1.setBackground(Color.BLACK); }else{ boton1.setBackground(Color.GREEN); } } }; boton1.addActionListener(c); final javax.swing.JButton boton2; boton2=new javax.swing.JButton(); boton2.setLocation(50,200); boton2.setSize(150,50); boton2.setBackground(Color.WHITE); this.add(boton2); java.awt.event.ActionListener d;

d=new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { if(boton2.getBackground()==Color.WHIT E){ boton2.setBackground(Color.RED); }else{ boton2.setBackground(Color.WHITE); } } }; boton2.addActionListener(d); final javax.swing.JButton boton3; boton3=new javax.swing.JButton(); boton3.setLocation(50,250); boton3.setSize(150,50); boton3.setBackground(Color.RED); this.add(boton3); java.awt.event.ActionListener f; f=new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { if(boton3.getBackground()==Color.RED){ boton3.setBackground(Color.YELLOW); }else{ boton3.setBackground(Color.RED); } } }; boton3.addActionListener(f); //codigo para el boton aseptar

final javax.swing.JButton botonasep; botonasep=new javax.swing.JButton("Aceptar"); botonasep.setLocation(50,350); botonasep.setSize(150,50); botonasep.setBackground(Color.YELLO W); this.add(botonasep); //evento de mouse java.awt.event.ActionListener a; a=new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { botonasep.setText("CANCELAR"); } }; botonasep.addActionListener (a); //CAMBIAR BOTON final javax.swing.JButton btncolor; btncolor=new javax.swing.JButton("Cambiar Color"); btncolor.setLocation(250,350); btncolor.setSize(150,50); btncolor.setBackground(Color.cyan); this.add(btncolor); //evento de mouse java.awt.event.ActionListener b; b=new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) {

if(btncolor.getBackground()==Color.cyan ){

btncolor.setBackground(Color.magenta) ; }else{ btncolor.setBackground(Color.cyan); } } }; btncolor.addActionListener(b); //botones para el semaforo final javax.swing.JButton botonf; botonf=new javax.swing.JButton(); botonf.setLocation(250,150); botonf.setSize(150,50); botonf.setBackground(Color.GREEN); this.add(botonf); java.awt.event.ActionListener o; o=new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) botonf.setText("Avansa carro"); System.out.println("Avansa carro"); javax.swing.JOptionPane.showMessage Dialog(null,"Avansa carro"); } }; botonf.addActionListener(o); final javax.swing.JButton botonf1; botonf1=new javax.swing.JButton(); botonf1.setLocation(250,200); botonf1.setSize(150,50); botonf1.setBackground(Color.YELLOW); this.add(botonf1); java.awt.event.ActionListener p; p=new java.awt.event.ActionListener() {

public void actionPerformed(ActionEvent e) { botonf1.setText("Disminulle carro"); System.out.println("Disminulle carro"); javax.swing.JOptionPane.showMessage Dialog(null,"Disminulle carro"); } }; botonf1.addActionListener(p); final javax.swing.JButton botonf2; botonf2=new javax.swing.JButton(); botonf2.setLocation(250,250); botonf2.setSize(150,50); botonf2.setBackground(Color.RED); this.add(botonf2); java.awt.event.ActionListener v; v=new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { botonf2.setText("Detener carro"); System.out.println("Detener carro"); javax.swing.JOptionPane.showMessage Dialog(null,"Detener carro"); } }; botonf2.addActionListener(v); this.setVisible(true); } }

GATO package gato; import gato.Gato; public class Main { public static void main(String[] args) { Gato Poncho; Poncho=new Gato(); Gato Toncho; Toncho=new Gato(); Gato Pancho; Pancho=new Gato(); Gato Ponchito; Ponchito=Poncho; Poncho.Maullar(); Toncho.Rasgunar(); Pancho.Jugar(); Ponchito.Pelear(); } } ackage gato; public class Gato { //atributos Bigotes bigote_izquierda; Bigotes bigote_derecha; Ojos ojo_izquierda; Ojos ojo_derecha; Patas p1,p2,p3,p4; Cola cola; //metodos public void Maullar() { System.out.println("el gato poncho maulla"); } public void Rasgunar() { System.out.println("el gato toncho rasgua"); } public void Jugar() { System.out.println("el gato pancho juega"); } public void Pelear() {

System.out.println("el gato ponchito pelea"); } } }

HERENCIA package herencia; public class Main { public static void main(String[] args) { Hijo juan=new Hijo(); juan.trabajar(); juan.llorar(); juan.jugar(); juan.desesperarse(); } } package herencia; public class Hijo extends Padre { public Hijo(){ } public void llorar(){ System.out.println("Me gusta llorar"); } } package herencia; public class Padre { public Padre(){ } String ojos="cafe",cabello="chino",colorpiel=" moreno"; Double altura=1.65; public void desesperarse(){ System.out.println("Quiero gritar"); } public void jugar(){ System.out.println("Soy deportista"); } public void trabajar(){ System.out.println("Me gusta llorar"); } }

MENU package menu; public class Main { public static void main(String[] args) { Colores formulario1=new Colores(); formulario1.setBounds(100,100,400,300 ); formulario1.setTitle("Menu de colores"); formulario1.setVisible(true); } } package menu; import java.awt.Color; import java.awt.Container; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; public class Colores extends JFrame implements ActionListener { //atributos de colores private JMenuBar mb; private JMenu menu1,menu2; private JMenuItem mi1,mi2,mi3,mi4,mi5,mi6,mi7,mi8,mi9, mi10; public Colores(){ javax.swing.JLabel etiqueta; etiqueta=new javax.swing.JLabel("MUNDO COLORES"); etiqueta.setLocation(120, 5); etiqueta.setSize(300,50); this.add(etiqueta); //// setLayout(null); mb=new JMenuBar(); setJMenuBar(mb); /// menu1=new JMenu("Espaol");

mb.add(menu1); menu2=new JMenu("Ingles"); mb.add(menu2); /// mi1=new JMenuItem("Rojo"); mi1.addActionListener(this); menu1.add(mi1); /// mi2=new JMenuItem("Verde"); mi2.addActionListener(this); menu1.add(mi2); /// mi3=new JMenuItem("Cafe"); mi3.addActionListener(this); menu1.add(mi3); /// mi4=new JMenuItem("Negro"); mi4.addActionListener(this); menu1.add(mi4); /// mi5=new JMenuItem("Blanco"); mi5.addActionListener(this); menu1.add(mi5); /// mi6=new JMenuItem("Yellow"); mi6.addActionListener(this); menu2.add(mi6); /// mi7=new JMenuItem("Pink"); mi7.addActionListener(this); menu2.add(mi7); //// mi8=new JMenuItem("Cyan"); mi8.addActionListener(this); menu2.add(mi8); /// mi9=new JMenuItem("Orange"); mi9.addActionListener(this); menu2.add(mi9); /// mi10=new JMenuItem("Purple"); mi10.addActionListener(this); menu2.add(mi10); }

public void actionPerformed(ActionEvent e) { Container f=this.getContentPane(); if(e.getSource()==mi1){ f.setBackground(new Color(255,0,0)); } if(e.getSource()==mi2){ f.setBackground(new Color(0,255,0)); } if(e.getSource()==mi3){ f.setBackground(new Color(102,0,0)); } if(e.getSource()==mi4){ f.setBackground(new Color(0,0,0)); } if(e.getSource()==mi5){ f.setBackground(new Color(255,255,255)); } if(e.getSource()==mi6){ f.setBackground(new Color(255,255,0)); } if(e.getSource()==mi7){ f.setBackground(new Color(255,0,255)); } if(e.getSource()==mi8){ f.setBackground(new Color(0,255,255)); } if(e.getSource()==mi9){ f.setBackground(new Color(255,153,0)); } if(e.getSource()==mi10){ f.setBackground(new Color(153,0,204)); } } }

PRIMER VENTANA package primerventana; public class Main { public static void main(String[] args) { Ventana v; v=new Ventana(); v.setX(450); v.setY(200); } } package primerventana; import java.awt.Color; public class Ventana extends javax.swing.JFrame{ private int x,y ; public Ventana(){ //codigo para el boton javax.swing.JButton botoncito; botoncito=new javax.swing.JButton("HOLA"); botoncito.setLocation(50,50); botoncito.setSize(250,50); this.add(botoncito); botoncito.setBackground(Color.YELLOW ); javax.swing.JButton botoncito1; botoncito1=new javax.swing.JButton("yesi"); botoncito1.setLocation(50,120); botoncito1.setSize(250,60); this.add(botoncito1); javax.swing.JLabel etiqueta; etiqueta=new javax.swing.JLabel("saludo"); etiqueta.setLocation(400,50); etiqueta.setSize(100,60); this.add(etiqueta); java.awt.Font h; h=new java.awt.Font("acmefont",1,19); etiqueta.setFont(h);

etiqueta.setForeground(Color.red); javax.swing.JLabel etiqueta1; etiqueta1=new javax.swing.JLabel("nombre"); etiqueta1.setLocation(400,120); etiqueta1.setSize(100,60); this.add(etiqueta1); h=new java.awt.Font("alegrian",1,19); etiqueta1.setFont(h); etiqueta1.setForeground(Color.orange); //codigo de la ventana this.setLayout(null); this.setSize(500,300); this.setVisible(true); this.setAlwaysOnTop(true); this.setTitle("mi primer ventana"); javax.swing.JLabel etiqueta2; etiqueta2=new javax.swing.JLabel("OBJETOS EN JAVA"); etiqueta2.setLocation(600,60); etiqueta2.setSize(200,100); this.add(etiqueta2); javax.swing.JTextField caja; caja=new javax.swing.JTextField(); caja.setLocation(50, 190); caja.setSize(300, 30); this.add(caja); javax.swing.JTextArea ea; ea=new javax.swing.JTextArea(); ea.setLocation(50, 250); ea.setSize(300, 300); this.add(ea); } public void setX(int x1){ x=x1; this.setLocation(x,y); }

public void setY(int y1){ y=y1; this.setLocation(x,y); } public int getX(){ return x; } }

PROGRAMAS

Вам также может понравиться