Académique Documents
Professionnel Documents
Culture Documents
};
} termina la clase
Programa ejemplo;
import java.io.*;
class prog33{
public static void main(String[] args) {
alumno.inicializar();
alumno.desplegar();
} // cierra main
} // cierra clase
class alumno{
void alumno(){};
static String nombre= new String();
static int edad;
static void inicializar(){
alumno.nombre="pepe el toro";
alumno.edad=18; };
static void desplegar(){
System.out.println(alumno.nombre);
System.out.println(alumno.edad);
};
} // temina la clase
bueno aqui les dejo el codigo de camara ip en java el cual puedes ver en tiempo real lo que pasa
en el mundo, tiene diferentes ips y a la cual ustedes pueden aadir extras para ver la camarita ,
tambien pueden ingresar el tiempo en que va a refrescar la camara, y ademas comoe xtra
acomodar el tamao de la imagen de la camara si mas ancho mas alto.
bueno vamos para el codigo primero obvio creamos un proyecto y luego creamos un pakete yo lo
voy a llamar camaraonline dentro de ese pakete creamos una clase llamada dibujartodo y en esa
clase ponemos el siguiente codigo:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package camaraonline;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JPanel;
/**
*
* @author andres2288
*/
public class dibujartodo extends JComponent{
d.width=358;
d.height=500;*/
this.pa=p;
}
@Override
public void paint(Graphics g){
super.paint(g);
//
getGrafo().paint(g);
try {
//libera lo que se halla almacenado en el buffer
snap.flush();
//carga la nueva imagen
/* ----------------- */
//Odate street
//snap = new ImageIcon(new URL("http://www.odate-
houjinkai.or.jp/snap.jpg")).getImage();
//tienda japon
//snap = new ImageIcon(new
URL("http://www.hifido.co.jp/camera/osu.jpg")).getImage();
//barberia japon
//snap = new ImageIcon(new URL("http://www.salonnet.org/realtime100.jpg")).getImage();
//Camaras AXIS
//aeropuerto de rochester
//snap = new ImageIcon(new
URL("http://84.92.80.192:8081/axis-cgi/jpg/image.cgi?
resolution=352x240")).getImage();
//snap = new ImageIcon(new
URL("http://206.127.116.63/axis-cgi/jpg/image.cgi?
resolution=352x240")).getImage();
//snap = new ImageIcon(new URL("http://62.42.19.194/axiscgi/jpg/image.cgi?resolution=352x240")).getImage();
//tokio
//snap = new ImageIcon(new
URL("http://221.255.120.171/axis-cgi/jpg/image.cgi?
resolution=352x240")).getImage();
//restorant
//snap = new ImageIcon(new URL( "http://80.25.78.169/" +
this.Axis )).getImage();
//calle
System.out.println(""+x1+"-->"+y1+"\n"+"pox"+getPosx()
+"posy"+getPosy()+"\n"+pa.getY());
if(mundo.indexOf("jpg")!=-1){
snap = new ImageIcon(new URL(mundo)).getImage();
}
else{
snap = new ImageIcon(new URL( mundo +
this.Axis )).getImage();
}
/* ----------------- */
} catch (MalformedURLException ex) {
}
g.drawImage(snap, 0, 0, x1, y1,
null);
}
//metodo que descarga una imagen de internet y la coloca en
el JLabel
private void Cargar_Imagen(){
try {
//libera lo que se halla almacenado en el buffer
snap.flush();
//carga la nueva imagen
/* ----------------- */
//Odate street
//snap = new ImageIcon(new URL("http://www.odatehoujinkai.or.jp/snap.jpg")).getImage();
//tienda japon
//snap = new ImageIcon(new
URL("http://www.hifido.co.jp/camera/osu.jpg")).getImage();
//barberia japon
//snap = new ImageIcon(new URL("http://www.salonnet.org/realtime100.jpg")).getImage();
//Camaras AXIS
//aeropuerto de rochester
//snap = new ImageIcon(new
URL("http://84.92.80.192:8081/axis-cgi/jpg/image.cgi?
resolution=352x240")).getImage();
//snap = new ImageIcon(new
URL("http://206.127.116.63/axis-cgi/jpg/image.cgi?
resolution=352x240")).getImage();
//snap = new ImageIcon(new URL("http://62.42.19.194/axiscgi/jpg/image.cgi?resolution=352x240")).getImage();
//tokio
//snap = new ImageIcon(new
URL("http://221.255.120.171/axis-cgi/jpg/image.cgi?
resolution=352x240")).getImage();
//restorant
//snap = new ImageIcon(new URL( "http://80.25.78.169/" +
this.Axis )).getImage();
//calle
snap = new ImageIcon(new URL( "http://123.220.250.252/" +
this.Axis )).getImage();
/* ----------------- */
} catch (MalformedURLException ex) {
}
@Override
public void run()
{
try
{
while(true)
{
//aumentamos dependiendo
pa.repaint();
hilo1.sleep(getTiempo());
System.out.println(""+tiempo);
}
} catch (java.lang.InterruptedException ie)
{ System.out.println(ie.getMessage()); }
}
};
*/
public Thread getHilo1() {
return hilo1;
}
/**
* @param hilo1 the hilo1 to set
*/
public void setHilo1(Thread hilo1) {
this.hilo1 = hilo1;
}
/**
* @return the tiempo
*/
public int getTiempo() {
return tiempo;
}
/**
* @param tiempo the tiempo to set
*/
public void setTiempo(int tiempo) {
this.tiempo = tiempo;
}
/**
* @return the mundo
*/
public String getMundo() {
return mundo;
}
/**
/**
* @return the posx
*/
public int getPosx() {
return posx;
}
/**
* @param posx the posx to set
*/
public void setPosx(int posx) {
this.posx = posx;
}
/**
* @return the posy
*/
public int getPosy() {
return posy;
}
/**
* @param posy the posy to set
*/
public void setPosy(int posy) {
this.posy = posy;
}
/**
* @return the y1
*/
public int getY1() {
return y1;
}
/**
* @param y1 the y1 to set
*/
public void setY1(int y1) {
this.y1 = y1;
}
}
luego creamos un formulario Jframe como lo entiendan llamado visual ponemos las siguientes
variables en ese formulario.
super("por andres2288");
initComponents();
contenedor= new dibujartodo(panel1,panel1);
dc1.addElement("http://123.220.250.252/");
dc1.addElement("http://www.odatehoujinkai.or.jp/snap.jpg");
dc1.addElement("http://www.hifido.co.jp/camera/osu.jpg");
dc1.addElement("http://www.salon-net.org/realtime100.jpg");
dc1.addElement("http://84.92.80.192:8081/axiscgi/jpg/image.cgi?resolution=352x240");
dc1.addElement("http://206.127.116.63/axiscgi/jpg/image.cgi?resolution=352x240");
dc1.addElement("http://62.42.19.194/axis-cgi/jpg/image.cgi?
resolution=352x240");
dc1.addElement("http://221.255.120.171/axiscgi/jpg/image.cgi?resolution=352x240");
dc1.addElement("http://128.97.43.214/");
creamos un boton llamado play y cuando le den click va a ejecutar el siguiente codigo
if(!contenedor.getHilo1().isAlive()){
contenedor.getHilo1().start();
}
else{
contenedor.getHilo1().resume();
}
bueno ustedes le agregan lo otro ya que es facil y eso es todo.
aqui les dejo el .jar descarga