miércoles, 1 de julio de 2009

Final




package temperatura;


import java.awt.Color;
import javax.swing.JApplet;
import java.awt.Graphics;
import javax.swing.JOptionPane;




public class NewJApplet extends JApplet {

public void init(){
//this.setSize(800, 450);

}

public void paint(Graphics g){
//this.setSize(800, 450);

g.setColor(Color.RED);
g.drawString("TEMPERATURA", 100 , 30);

g.setColor(Color.BLACK);
g.drawOval(20, 30, 50, 50);
g.drawRect(200 ,50 , 20, 100);
g.drawString("-10 ºC", 230, 160);
g.drawString("100 ºC", 230, 50);
String aux = JOptionPane.showInputDialog(null,"INGRESE EL VALOR DE LA TEMPERATURA","titulo",JOptionPane.DEFAULT_OPTION);
int temp = Integer.parseInt(aux);
g.drawString("+"+temp+" C", 230, 150-temp);
g.setColor(Color.BLUE);
if(temp >70){
g.setColor(Color.RED);
g.fillOval(20, 30, 50, 50);
g.fillRect(200, 50, 20, 100-temp);
g.drawString("ALERTA", 30 , 20);
}

if(temp <10){
g.setColor(Color.RED);
g.fillOval(20, 30, 50, 50);
g.fillRect(200, 50, 20, 100-temp);
g.drawString("ALERTA", 30 , 20);
}

g.fillOval(20, 30, 50, 50);
g.fillRect(200, 50, 20, 100-temp);


g.drawOval(100, 50, 100,100 );
g.setColor(Color.BLUE);
if(temp >70){
g.setColor(Color.RED);

g.fillArc(100, 50,100 ,100 ,0, (temp*360)/100);
}
g.fillArc(100, 50,100 ,100 ,0,(temp*360)/100);

if(temp <10){
g.setColor(Color.RED);

g.fillArc(100, 50,100 ,100 ,0, (temp*360)/100);
}
g.fillArc(100, 50,100 ,100 ,0,(temp*360)/100);

}
}

miércoles, 24 de junio de 2009

Prueba






package prueba;

import javax.swing.JApplet;
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JOptionPane;

/**
*
* @author program
*/
public class Prueba extends JApplet {
public void init() {

}
// TODO start asynchronous download of heavy resources
public void paint(Graphics g){

g.drawOval(100, 50, 100, 100);

int angulo=115;
int r=10;
int t=2;
int w;
int Wo=0;
double Wf;
double Vf;
int[]v=new int[2];
double []a=new double[2];
double a1;
double v1;

v[0]=-10; v[1]=-20;
a[0]=-2.3; a[1]=-1.8;

g.setColor(Color.BLUE);
g.drawString("DATOS:", 250, 30);
g.setColor(Color.BLACK);
g.drawString("r = 10m :", 250, 45);
g.drawString("t = 2s :", 250, 60);
g.drawString("V = (-10, -20)m/s", 250, 75);

g.setColor(Color.BLUE);
g.drawString("RESPUESTAS: ", 250, 110);
g.setColor(Color.BLACK);
g.drawString("α = 115º", 150, 120);
g.setColor(Color.GREEN);
g.fillArc(100, 50,100 ,100 ,0, (angulo));
g.setColor(Color.black);
g.fillOval(147, 96, 8, 8);
g.fillOval(126, 52, 8, 8);
g.drawLine(150, 100, 129, 53);


w=angulo/t;
g.drawString("W ="+w, 250, 125);
v1= Math.sqrt(Math.pow(v[0], 2) + Math.pow(v[1], 2));
a1 = Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2));
Wf= Wo + a1 * t;
g.drawString("Wf ="+Wf, 250, 140);
Vf= r*w;
g.drawString("Vf ="+Vf, 250, 155);

}
}

miércoles, 10 de junio de 2009

Dinamica cplto...






import javax.swing.JApplet;
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JOptionPane;

/**
*
* @author program
*/
public class Dinamica extends JApplet {


public void init() {

}

public void paint(Graphics g){

String aux=JOptionPane.showInputDialog(null,"INGRESE EL VALOR DE LA BASE","BASE",JOptionPane.PLAIN_MESSAGE);
double x= Double.parseDouble(aux);
g.drawLine(30,150,(int)x+30,150 );
String aux2=JOptionPane.showInputDialog(null,"INGRESE EL VALOR DE LA ALTURA","ALTURA",JOptionPane.DEFAULT_OPTION);
double y =Double.parseDouble(aux2);
g.drawLine((int)x+30, 150,(int)x+30,150-(int)y);
g.drawLine(30, 150, (int)x+30, 150-(int)y);

double angulo;
double tan=y/x;
angulo=Math.atan(tan);
angulo=Math.toDegrees(angulo);

String aux8=JOptionPane.showInputDialog(null,"INGRESE LA DISTANCIA a DE LA MASA","INGRESE DISTANCIA a",JOptionPane.DEFAULT_OPTION);
double ab=Double.parseDouble(aux8);
double c=ab*Math.cos(angulo*Math.PI/180);
double xo=30+c;
double l=ab*Math.sin(angulo*Math.PI/180);
double yo=150-l;
double d=20*Math.cos(angulo*Math.PI/180);
double xo1=xo+d;
double m=(c+d)*Math.tan(angulo*Math.PI/180);
double yo1=150-m;
g.setColor(Color.BLACK);
g.drawLine((int)xo,(int)yo,(int)xo1,(int)yo1);
double dx=10*Math.sin(angulo*Math.PI/180);
double dy=10*Math.cos(angulo*Math.PI/180);
double xo2=xo1-dx;
double yo2=yo1-dy;
g.drawLine((int)xo1,(int)yo1,(int)xo2,(int)yo2);
g.drawLine((int)xo2,(int)yo2,(int)(xo-dx),(int)(yo-dy));
g.drawLine((int)(xo-dx),(int)(yo-dy),(int)xo,(int)yo);



String aux3=JOptionPane.showInputDialog(null,"INGRESE EL VALOR DE LA FUERZA","FUERZA EN NEWTONS",JOptionPane.DEFAULT_OPTION);
double fuerza=Double.parseDouble(aux3);
String aux4=JOptionPane.showInputDialog(null,"INGRESE EL VALOR DE LA MASA","MASA EN KILOGRAMOS",JOptionPane.DEFAULT_OPTION);
double masa=Double.parseDouble(aux4);

String aux5=JOptionPane.showInputDialog(null,"INGRESE EL VALOR DEL COEFICIENTE DE ROZAMIENTO","COEFICIENTE DE ROZAMIENTO",JOptionPane.DEFAULT_OPTION);
double miu=Double.parseDouble(aux5);

String aux6=JOptionPane.showInputDialog(null,"INGRESE EL TIEMPO","TIEMPO EN SEGUNDOS",JOptionPane.DEFAULT_OPTION);
double tiempo=Double.parseDouble(aux6);

double gravedad=9.8;
double aceleracion;
aceleracion=(fuerza/masa)-(gravedad*((miu*Math.cos(angulo*Math.PI/180))+Math.sin(angulo*Math.PI/180)));
double desplazamiento= aceleracion*0.5*tiempo*tiempo;
double xn=desplazamiento*Math.cos(angulo*Math.PI/180);
double yn=desplazamiento*Math.sin(angulo*Math.PI/180);
g.setColor(Color.RED);
g.drawLine((int)(xo+xn),(int)(yo-yn), (int)(xo1+xn), (int)(yo1-yn));
g.drawLine((int)(xo1+xn),(int)(yo1-yn),(int)(xo2+xn),(int)(yo2-yn) );
g.drawLine((int)(xo2+xn),(int)(yo2-yn),(int)(xo+xn-dx),(int)(yo-yn-dy) );
g.drawLine((int)(xo+xn-dx),(int)(yo-yn-dy),(int)(xo+xn),(int)(yo-yn) );


g.setColor(Color.BLUE);
double yb=5*Math.sin((angulo)*Math.PI/180);
double xb=5*Math.cos((angulo)*Math.PI/180);
double frx=0.1*miu*masa*gravedad*Math.cos(angulo*Math.PI/180);
double fry=0.1*miu*masa*gravedad*Math.sin(angulo*Math.PI/180);
g.drawLine((int)(xo+xn-xb+(0.5*d)),(int)(yo-yn-yb-dx),(int)(xo+xn-xb+(0.5*d)-frx),(int)(yo-yn-yb-dx+fry) );
g.drawString("fr",(int)(xo+xn-xb+(0.5*d)-frx-15),(int)(yo-yn-yb-dx+fry));

g.setColor(Color.MAGENTA);
double ny=0.1*masa*gravedad*Math.cos(angulo*Math.PI/180);
double nx=0.1*masa*gravedad*Math.sin(angulo*Math.PI/180);
g.drawLine((int)(xo+xn-xb+(0.5*d)),(int)(yo-yn-yb-dx),(int)(xo+xn-xb+(0.5*d)-nx),(int)(yo-yn-yb-dx-ny) );
g.drawString("FN",(int)(xo+xn-xb+(0.5*d)-nx-20),(int)(yo-yn-yb-dx-ny));
g.setColor(Color.green);
double fx=0.1*fuerza*Math.cos(angulo*Math.PI/180);
double fy=0.1*fuerza*Math.sin(angulo*Math.PI/180);
g.drawLine((int)(xo+xn-xb+(0.5*d)),(int)(yo-yn-yb-dx),(int)(xo+xn-xb+(0.5*d)+fx),(int)(yo-yn-yb-dx-fy) );
g.drawString("F",(int)(xo+xn-xb+(0.5*d)+fx-15),(int)(yo-yn-yb-dx-fy));

g.setColor(Color.orange);
double peso=0.1*masa*gravedad;
g.drawLine((int)(xo+xn-xb+(0.5*d)),(int)(yo-yn-yb-dx),(int)(xo+xn-xb+(0.5*d)),(int)(yo-yn-yb-dx+peso) );
g.drawString("P",(int)(xo+xn-xb+(0.5*d)-15),(int)(yo-yn-yb-dx+peso));


g.setColor(Color.BLACK);
g.drawString("FUERZA = ", 260,44);
g.drawString("MASA =", 270,59);
g.drawString("TIEMPO =", 260,74);
g.drawString("MIU =", 280,89);
g.drawString("ACEL =", 270,104);
g.drawString("DESPLA =", 260,119);
g.drawString("LA NORMAL =", 230,134);
g.drawString("ANG PLANO =", 230,149);
g.drawString("b =",30+(int)x/2,170);
g.drawString("h =",(int)x+40,160-(int)y/2);

g.setColor(Color.BLACK);
g.drawString(""+(int)x,50+(int)x/2,170);
g.drawString(""+(int)y,(int)x+60,160-(int)y/2);
g.drawString(""+(short)angulo, 322,149);
g.drawString(""+fuerza, 322,44);
g.drawString(""+(short)masa, 322,59);
g.drawString(""+tiempo, 322,74);
g.drawString(""+miu, 322,89);
g.drawString(""+miu, 322,89);
g.drawString(""+(short)aceleracion, 322,104);
g.drawString(""+(short)desplazamiento, 322,119);
g.drawString(""+(short)(miu*masa*gravedad*Math.cos(angulo*Math.PI/180)), 322,134);
}
}

lunes, 8 de junio de 2009

Ej. Dinamica




import java.applet.Applet;
import java.awt.*;
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JApplet;
import javax.swing.JOptionPane;


public class Fisica extends Applet{
public void paint(Graphics g){


String aux=JOptionPane.showInputDialog(null, "Ingrese el valor Hipotenusa","titulo", JOptionPane.DEFAULT_OPTION);
int temp=Integer.parseInt(aux);
g.drawLine(50, 180,180, 50);

String aux1=JOptionPane.showInputDialog(null, "Ingrese el valor de X","titulo", JOptionPane.DEFAULT_OPTION);
int tem=Integer.parseInt(aux1);
g.drawLine(50, 180, 180,180);

String aux2=JOptionPane.showInputDialog(null, "Ingrese el valor de la Altura","titulo", JOptionPane.DEFAULT_OPTION);
int temp1=Integer.parseInt(aux2);
g.drawLine(180, 50, 180, 180);

}
}

miércoles, 3 de junio de 2009

Temperatura







package temperatura;
import java.awt.Color;
import javax.swing.JApplet;
import java.awt.Graphics;
import javax.swing.JOptionPane;


public class temperatura extends JApplet {

public void init(){
//this.setSize(800, 450);

}

public void paint(Graphics g){
//this.setSize(800, 450);
g.setColor(Color.RED);
g.drawString("TEMPERATURA", 190 , 30);
// g.drawString("ALERTA", 500 , 50);
g.setColor(Color.BLACK);
g.drawOval(20, 30, 50, 50);
g.drawRect(200 ,50 , 20, 100);
g.drawString("-10 ºC", 230, 150);
g.drawString("100 ºC", 230, 50);
String aux = JOptionPane.showInputDialog(null,"INGRESE EL VALOR DE LA TEMPERATURA","titulo",JOptionPane.DEFAULT_OPTION);
int temp = Integer.parseInt(aux);
g.drawString("+"+temp+" C", 230, 150-temp);
g.setColor(Color.BLUE);
if(temp >80){
g.setColor(Color.RED);
g.fillOval(20, 30, 50, 50);
g.fillRect(200, 50, 20, 100-temp);
g.drawString("ALERTA", 30 , 10);

}
g.fillOval(20, 30, 50, 50);
g.fillRect(200, 50, 20, 100-temp);

}
}

miércoles, 27 de mayo de 2009

Demo Panel









package demopanel;

/**
*
* @author program
*/
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

public class DemoPanel extends JFrame {

Container contenedor;
private JPanel panelInicio;
private JPanel panelFin;
private JPanel PanelMedio;
private JPanel PanelMedio1;
private JButton [][] botones;
private JLabel[][] texto;
private JTextField[][] texto1;


public DemoPanel(){

super("Mi panel de Prueba");
botones = new JButton[2][2];
contenedor = getContentPane();
panelInicio = new JPanel(new GridLayout(2,2));


String [] nombres = {"Enero","Febrero","Marzo","Abril"};
/* botones[0][0]= new JButton("enero");
botones[0][1]= new JButton("Febrero");
botones[1][0]= new JButton("Marzo");
botones[1][1]= new JButton("Abril");
*/
int k=0;
for(int i=0; i<2; i++){
for(int j=0;j<2; j++){
botones[i][j] = new JButton(nombres[k]);
k += 1;
panelInicio.add(botones[i][j]);
}
}
contenedor.add(panelInicio,BorderLayout.NORTH);
setSize(425,150);
setVisible(true);

texto = new JLabel[5][5];
panelFin = new JPanel(new GridLayout(5,5,10,10));
for(int i=0; i<5; i++){
for(int j=0; j<5; j++){
texto[i][j]= new JLabel("texto "+i+" "+j);
panelFin.add(texto[i][j]);

}
}
contenedor.add(panelFin,BorderLayout.SOUTH);

texto1 = new JTextField[4][3];
PanelMedio = new JPanel(new GridLayout(5,5,10,10));
for(int i=0; i<4; i++){
for(int j=0; j<3; j++){
texto1[i][j]= new JTextField("texto "+i+" "+j);
PanelMedio.add(texto1[i][j]);

}
}
contenedor.add(PanelMedio,BorderLayout.WEST);

texto1 = new JTextField[2][4];
PanelMedio1 = new JPanel(new GridLayout(5,5,10,10));
for(int i=0; i<2; i++){
for(int j=0; j<4; j++){
texto1[i][j]= new JTextField("texto "+i+" "+j);
PanelMedio1.add(texto1[i][j]);

}
}
contenedor.add(PanelMedio1,BorderLayout.EAST);
}

public static void main(String args[]){
DemoPanel aplicacion = new DemoPanel();
aplicacion.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}

lunes, 25 de mayo de 2009

Evaluacion




import java.applet.Applet;
import java.awt.*;
public class SennoApplet extends Applet {
public void paint(Graphics g){
g.drawString("y= m * Sen(ax+b)",400 , 300);
g.drawString("y= m * Cos(ax+b)",400 , 179);
g.drawString("y= (a*x+b) ",250 , 100);

g.drawLine(40, 40, 40, 450);
g.drawLine(20, 270, 450, 270);
g.setColor(Color.LIGHT_GRAY);

int a=1;
int m=100;
int b=0;

for(int i=0;i<361; i=i+2){
g.fillOval( a*(38 + i)+b,(int) (265 - m *(Math.cos(i*3.1416/180))),6,6);}

g.setColor(Color.red);

for(int i=0;i<361; i=i+2){
g.fillOval( a*(38 + i)+b,(int) (265 - m *(Math.sin(i*3.1416/180))),6,6);}

g.setColor(Color.blue);

for(int i=0;i<361; i=i+2){

g.fillOval( a*(38 + i)+b,(int)266-(a*i)+b,6,6);}


g.setColor(Color.BLACK);
g.drawString("-1", 30, 370);
g.drawString("0", 30,270);
g.drawString("1", 30, 165);
g.drawString("¶/2", 115, 280);
g.drawString("¶", 205,280);
g.drawString("3¶/2", 285, 280);
g.drawString("2¶", 405, 280);
g.drawLine(40,40,35,55);
g.drawLine(35,55,45,55);
g.drawLine(45,55,40,40);
g.drawLine(450,270,425,265);
g.drawLine(425,265,425,275);
g.drawLine(425,275,450,270);
g.setColor(Color.RED);
g.drawString("X (Radianes)", 460, 270);
g.drawString("Y f(x)", 25, 35);
int ymax=this.getHeight();
int xmax=this.getWidth();
this.setSize(600, 500);
}