Bienvenidos a mi pagina jejeje
Recuerda que nuestro objetivo
Aqui dos programitas para lograrlo :)
Codigo PickMouse
--------------------------------------
import java.applet.*;
import java.awt.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.SimpleUniverse;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.image.TextureLoader;
import com.sun.j3d.utils.behaviors.picking.*;
import java.awt.image.*;
import java.awt.event.*;
public class PickMouse extends Frame implements KeyListener{
private Canvas3D canvas = null;
private Box box;
public PickMouse() {
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
canvas = new Canvas3D(config);
this.setLayout(new BorderLayout());
this.add(canvas, BorderLayout.CENTER);
SimpleUniverse universe = new SimpleUniverse(canvas);
universe.getViewingPlatform().setNominalViewingTransform();
BranchGroup scene = createSceneGraph();
universe.addBranchGraph(scene);
}
public void keyPressed(KeyEvent e){
}
public void keyReleased(KeyEvent e) {
}
public void keyTyped(KeyEvent e) {
}
private BranchGroup createSceneGraph() {
BranchGroup objRoot = new BranchGroup();
BoundingSphere bounds = new BoundingSphere( new Point3d(), 100.0 );
PickRotateBehavior rotacion =
new PickRotateBehavior(objRoot, canvas, bounds, PickObject.USE_GEOMETRY);
objRoot.addChild(rotacion);
PickTranslateBehavior desplazamiento =
new PickTranslateBehavior(objRoot, canvas, bounds, PickObject.USE_GEOMETRY);
objRoot.addChild(desplazamiento);
PickZoomBehavior zoom =
new PickZoomBehavior(objRoot, canvas, bounds, PickObject.USE_GEOMETRY);
objRoot.addChild(zoom);
TransformGroup trans = new TransformGroup();
objRoot.addChild(trans);
Transform3D cajaTrans3D = new Transform3D();
cajaTrans3D.set(new Vector3d(0.0, 0.0, 0.0));
TransformGroup cajaTrans = new TransformGroup(cajaTrans3D);
cajaTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
cajaTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
cajaTrans.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
trans.addChild(cajaTrans);
//Appearance app = new Appearance();
/****Aki esta lo de poner textos**************/
BufferedImage image1=new BufferedImage(256,256,BufferedImage.TYPE_INT_ARGB);
Graphics g= image1.getGraphics();
g.setFont(new Font("Arial",Font.BOLD,25));
g.drawString("Manuel",90,128);
BufferedImage image2=new BufferedImage(256,256,BufferedImage.TYPE_INT_ARGB);
g= image2.getGraphics();
g.setFont(new Font("Arial",Font.BOLD,25));
g.drawString("Kike",90,128);
BufferedImage image3=new BufferedImage(256,256,BufferedImage.TYPE_INT_ARGB);
g= image3.getGraphics();
g.setFont(new Font("Arial",Font.BOLD,25));
g.drawString("Churuchu",90,128);
BufferedImage image4=new BufferedImage(256,256,BufferedImage.TYPE_INT_ARGB);
g= image4.getGraphics();
g.setFont(new Font("Arial",Font.BOLD,25));
g.drawString("Ubuntu",90,128);
BufferedImage image5=new BufferedImage(256,256,BufferedImage.TYPE_INT_ARGB);
g= image5.getGraphics();
g.setFont(new Font("Arial",Font.BOLD,25));
g.drawString("Windows",90,128);
BufferedImage image6=new BufferedImage(256,256,BufferedImage.TYPE_INT_ARGB);
g= image6.getGraphics();
g.setFont(new Font("Arial",Font.BOLD,25));
g.drawString("Ivan",90,128);
/****Aki esta lo de poner textos**************/
Texture texture1 = new TextureLoader(image1, this).getTexture();
Texture texture2 = new TextureLoader(image2, this).getTexture();
Texture texture3 = new TextureLoader(image3, this).getTexture();
Texture texture4 = new TextureLoader(image4, this).getTexture();
Texture texture5 = new TextureLoader(image5, this).getTexture();
Texture texture6 = new TextureLoader(image6, this).getTexture();
Appearance app=new Appearance();
Appearance app1 = new Appearance();
app1.setTexture(texture1);
Appearance app2 = new Appearance();
app2.setTexture(texture2);
Appearance app3 = new Appearance();
app3.setTexture(texture3);
Appearance app4 = new Appearance();
app4.setTexture(texture4);
Appearance app5 = new Appearance();
app5.setTexture(texture5);
Appearance app6 = new Appearance();
app6.setTexture(texture6);
box =
new Box( 0.5f, 0.5f, 0.5f,
Primitive.GENERATE_TEXTURE_COORDS |
Primitive.ENABLE_GEOMETRY_PICKING | Primitive.ENABLE_APPEARANCE_MODIFY,app);
cajaTrans.addChild(box);
box.getShape(Box.BACK).setAppearance(app1);
box.getShape(Box.BOTTOM).setAppearance(app2);
box.getShape(Box.FRONT).setAppearance(app3);
box.getShape(Box.LEFT).setAppearance(app4);
box.getShape(Box.RIGHT).setAppearance(app5);
box.getShape(Box.TOP).setAppearance(app6);
Background bg = new Background(new Color3f(0.5f,0.5f,1.0f));
bg.setApplicationBounds(bounds);
objRoot.addChild(bg);
return objRoot;
}
private Appearance app() {
Appearance app = new Appearance();
Image image = null;
Toolkit toolkit = Toolkit.getDefaultToolkit();
image = toolkit.getImage("seco.jpg");
MediaTracker mt = new MediaTracker(this);
mt.addImage(image, 0);
mt.checkAll(true);
try { mt.waitForID(0); } catch (InterruptedException e) { e.printStackTrace(); }
Texture texture = new TextureLoader(image, this).getTexture();
app.setTexture(texture);
return app;
}
public static void main(String[] args) {
PickMouse applet = new PickMouse();
applet.setVisible(true);
applet.setSize(500,500);
applet.setTitle("Ventanita");
// Frame frame = new MainFrame(applet, 300, 300);
}
}
Codigo Listado
--------------------------
import java.sql.*;
public class Listado {
public static void main(String[] args){
String Nombre,Apellido,DNI;
int Edad;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String BaseDeDatos = "jdbc:odbc:NombreLogico";
Connection Conexion = DriverManager.getConnection(BaseDeDatos);
Statement SentenciaSQL = Conexion.createStatement();
ResultSet Personas = SentenciaSQL.executeQuery("SELECT * FROM DatosPersonales");
while (Personas.next()) {
DNI = Personas.getString("DNI");
Nombre = Personas.getString("Nombre");
Apellido = Personas.getString("Apellido");
Edad = Personas.getInt("Edad");
System.out.println(Nombre+" "+Apellido+", "+Edad+", "+DNI);
}
Personas.close();
Conexion.close();
SentenciaSQL.close();
}
catch (ClassNotFoundException e) {
System.out.println("Clase no encontrada");
}
catch (SQLException e) {
System.out.println(e);
}
}
}