Ayuda con applet

edimmu
12 de Abril del 2010
Estoy intentando un graficador de vectores (física), desafortunadamente no corre, esto es lo que he hecho:

import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;

class VectorialC extends Applet {
private nVectors v = new nVectors();
private JButton calc;
private JButton delt;
private double vBase[][] = new double [6][3];
private JScrollPane sp;
private JOptionPane msg = new JOptionPane ();
private CoordC cC = new CoordC ();
private Canvas c;
private JPanel panel = new JPanel ();

public void init () {
try {
jInit();
}
catch (Exception e) {
e.printStackTrace();
}
}

public void jInit () throws Exception {

calc = new JButton("Calcular");
setBackground(Color.white);
add(v,BorderLayout.WEST);
c = new Canvas ();
reshape(0,0,50,50);
sp = new JScrollPane(c);
panel.add(sp);
add(panel,BorderLayout.CENTER);
add(calc,BorderLayout.EAST);
add(calc,BorderLayout.EAST);
}

public void paintCallback( Graphics g ) {
int x2 = (int)vBase[0][2];
int y2 = (int)vBase[1][2];
int x1 = x2-30;
int y1 = y2-30;

g.drawLine( x1,y1,x2,y2 );
}

public boolean action( Event evt,Object obj ) {
if( obj.equals( "Calcular" ) )
{
v.fillV();
for (int i=0; i<6; i++) {
for (int j=0; j<3; j++) {
vBase[i][j]=v.getV(i,j);
}
}
if ((int)vBase[0][0]==0 && (int)vBase[1][0]==0 && (int)vBase[2][0]==0) {
vBase[0][0]=cC.convX(vBase[3][0],vBase[4][0],vBase[5][0]);
vBase[1][0]=cC.convY(vBase[3][0],vBase[4][0],vBase[5][0]);
vBase[2][0]=cC.convZ(vBase[3][0],vBase[4][0],vBase[5][0]);
}
else {
if ((int)vBase[3][0]==0 && (int)vBase[4][0]==0 && (int)vBase[5][0]==0) {
vBase[3][0]=cC.convR(vBase[0][0],vBase[1][0],vBase[2][0]);
vBase[4][0]=cC.convA(vBase[0][0],vBase[1][0],vBase[2][0]);
vBase[5][0]=cC.convB(vBase[0][0],vBase[1][0],vBase[2][0]);
}
}
if ((int)vBase[0][1]==0 && (int)vBase[1][1]==0 && (int)vBase[2][1]==0) {
vBase[0][1]=cC.convX(vBase[3][1],vBase[4][1],vBase[5][1]);
vBase[1][1]=cC.convY(vBase[3][1],vBase[4][1],vBase[5][1]);
vBase[2][1]=cC.convZ(vBase[3][1],vBase[4][1],vBase[5][1]);
}
else {
if ((int)vBase[3][1]==0 && (int)vBase[4][1]==0 && (int)vBase[5][1]==0) {
vBase[3][1]=cC.convR(vBase[0][1],vBase[1][1],vBase[2][1]);
vBase[4][1]=cC.convA(vBase[0][1],vBase[1][1],vBase[2][1]);
vBase[5][1]=cC.convB(vBase[0][1],vBase[1][1],vBase[2][1]);
}
}
vBase[0][2] = vBase[0][0]+vBase[0][1];
vBase[1][2] = vBase[1][0]+vBase[1][1];
vBase[2][2] = vBase[2][0]+vBase[2][1];
vBase[3][2] = cC.convR(vBase[0][2],vBase[1][2],vBase[2][2]);
vBase[4][2] = cC.convR(vBase[0][2],vBase[1][2],vBase[2][2]);
vBase[5][2] = cC.convR(vBase[0][2],vBase[1][2],vBase[2][2]);
for (int i=0; i<6; i++) {
for (int j=0; j<3; j++) {
v.setV(vBase[i][j],i,j);
}
}

c.repaint();
return( true );
}
return( false );
}

public Dimension preferredSize() {
return new Dimension( 500,200 );
}

public static void main(String[] args) {
Frame f = new Frame("Calculadora Vectorial");
VectorialC vc = new VectorialC ();
vc.init();
f.add(vc);
f.pack();
f.show();
}
}

NooK
12 de Abril del 2010
Hola edimmu, por favor pone el codigo de las clases CoorD y nVector, tambien tenes un error de programacion cuando asignas Calculadora Vectorial tenes una slash (barra) fuera de las comillas revisalo! saludos!