Ver Mensaje Individual
  #3 (permalink)  
Antiguo 24/06/2009, 15:19
Zent
 
Fecha de Ingreso: junio-2009
Mensajes: 2
Antigüedad: 15 años, 8 meses
Puntos: 0
Ayuda en tablas

Ok, si ya lei mi mensaje y si lo escribi bastante mal, era por las prisas y las preocupaciones, pero si tenias razon, quiero rellenar datos de la tabla con esos valores ok.. muestro lo que he hecho hasta ahorita:
Object[][] _datos={prueba, temp_1};

String[] _columnas = {"Nombre", "Propiedades"};
final JTable table = new JTable(_datos,_columnas);
table.setPreferredScrollableViewportSize(new Dimension(300, 70));

//Creamos un JscrollPane y le agregamos la JTable
JScrollPane scrollPane = new JScrollPane(table);
getContentPane().add(scrollPane, BorderLayout.EAST);

Con esto estoy, creando mi tabla.... el problema es que no puedo pasar valores a mis celdas, de cuando las extraigo de la ontología... cheque lo tuyo pero por ejemplo al moento de crear mis variables String me marca que no son reconocidas :s... y no es la gran cosa seguire intentado igual... con esto ya me diste una idea mas o menos de como realizarlo pero ahora lo estoy manejando a puro lenguaje sin utilizar el jigloo y asi me resulta mas facil de entender el codigo por que lo creo y manipulo yo... ya no mi maq.... no se si me de a entender... solo quiero rellenar mi tabla con los datos que extraigo... de la temp_1

Igual dejo el codigo completo a continuacion:



public class Ven_1 extends javax.swing.JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
JTextField jtf;
private JTree jTree1;
private JTable jTable1;
String prueba,dato1,dato2,temp_1;
int contador=0;
static private JenaOWLModel owlModel=null;


public static void main(String[] args) {
//TODO:Cargar ontología

//----------
File file =new File("C:/Baco/ontology.rdf-xml.owl");
URI _turi=null;
URL _url=null;
try{
_turi=file.toURI();
_url=_turi.toURL();
}
catch(MalformedURLException _ei){
System.out.println(_ei.getMessage());
}
String _uri=_url.toString();
try{
JenaOWLModel owlModel=ProtegeOWL.createJenaOWLModelFromURI(_uri );
}
catch(Exception _e1){
System.out.println("Error: "+ _e1.getMessage());
System.out.println("No se encontro la ontologia");
}


SwingUtilities.invokeLater(new Runnable() {
public void run() {
Ven_1 inst = new Ven_1();
inst.setLocationRelativeTo(null);
inst.setVisible(true);
}
});
}

public Ven_1() {
super();
initGUI();

}

private void initGUI() {
try {
BorderLayout thisLayout = new BorderLayout();
setDefaultCloseOperation(WindowConstants.DISPOSE_O N_CLOSE);
getContentPane().setLayout(thisLayout);


{
jTree1 = new JTree();
getContentPane().add(jTree1, BorderLayout.WEST);
int v= ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h= ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED ;
JScrollPane jsp=new JScrollPane(jTree1,v,h);

add(jsp,BorderLayout.WEST);
}
pack();
setSize(600, 300);
} catch (Exception e) {
e.printStackTrace();
}
//TODO: Creación del arbol y su poblacion
DefaultMutableTreeNode RaizOnt=new DefaultMutableTreeNode("Ontologia");
DefaultTreeModel ArbolOnt = new DefaultTreeModel(RaizOnt);
jTree1.setModel(ArbolOnt);
jTree1.setPreferredSize(new java.awt.Dimension(120, 272));
//---------------------
DefaultMutableTreeNode Actions=new DefaultMutableTreeNode("Actions");
RaizOnt.add(Actions);
DefaultMutableTreeNode Actors=new DefaultMutableTreeNode("Actors");
RaizOnt.add(Actors);
DefaultMutableTreeNode Collisions=new DefaultMutableTreeNode("Collisions");
RaizOnt.add(Collisions);
DefaultMutableTreeNode Enviroment=new DefaultMutableTreeNode("Enviroment");
RaizOnt.add(Enviroment);
DefaultMutableTreeNode Keywords=new DefaultMutableTreeNode("Keywords");
RaizOnt.add(Keywords);
DefaultMutableTreeNode Laws=new DefaultMutableTreeNode("Laws");
RaizOnt.add(Laws);
DefaultMutableTreeNode Objects=new DefaultMutableTreeNode("Objects");
RaizOnt.add(Objects);
//-----------CREACION DE LAS CLASES DE ACTIONS-------------
DefaultMutableTreeNode actions_damage=new DefaultMutableTreeNode("Damage");
Actions.add(actions_damage);
DefaultMutableTreeNode actions_dance=new DefaultMutableTreeNode("Dance");
Actions.add(actions_dance);
DefaultMutableTreeNode actions_destroy=new DefaultMutableTreeNode("Destroy");
Actions.add(actions_destroy);
DefaultMutableTreeNode actions_float=new DefaultMutableTreeNode("Float");
Actions.add(actions_float);
DefaultMutableTreeNode actions_jounce=new DefaultMutableTreeNode("Jounce");
Actions.add(actions_jounce);
DefaultMutableTreeNode actions_jum=new DefaultMutableTreeNode("Jum");
Actions.add(actions_jum);
DefaultMutableTreeNode actions_move_to_left=new DefaultMutableTreeNode("Move to left");
Actions.add(actions_move_to_left);
DefaultMutableTreeNode actions_move_to_right=new DefaultMutableTreeNode("Move to rigth");
Actions.add(actions_move_to_right);
DefaultMutableTreeNode actions_shot=new DefaultMutableTreeNode("Shot");
Actions.add(actions_shot);
DefaultMutableTreeNode actions_turn_left=new DefaultMutableTreeNode("Turn left");
Actions.add(actions_turn_left);
DefaultMutableTreeNode actions_turn_right=new DefaultMutableTreeNode("Turn rigth");
Actions.add(actions_turn_right);
DefaultMutableTreeNode actions_walk=new DefaultMutableTreeNode("Walk");
Actions.add(actions_walk);
//------------CREACION DE LAS CLASES DE ACTORS--------------
DefaultMutableTreeNode actors_frog=new DefaultMutableTreeNode("Frog");
Actors.add(actors_frog);
DefaultMutableTreeNode actors_hombre_expreciones=new DefaultMutableTreeNode("Hombre Expreciones");
Actors.add(actors_hombre_expreciones);
DefaultMutableTreeNode actors_hombre_negro=new DefaultMutableTreeNode("Hombre Negro");
Actors.add(actors_hombre_negro);
DefaultMutableTreeNode actors_hombre_verde=new DefaultMutableTreeNode("Hombre verde");
Actors.add(actors_hombre_verde);
DefaultMutableTreeNode actors_knight=new DefaultMutableTreeNode("Knight");
Actors.add(actors_knight);
DefaultMutableTreeNode actors_man=new DefaultMutableTreeNode("Man");
Actors.add(actors_man);
DefaultMutableTreeNode actors_mujer_esqueleto=new DefaultMutableTreeNode("Mujer esqueleto");
Actors.add(actors_mujer_esqueleto);
DefaultMutableTreeNode actors_mujer_negro=new DefaultMutableTreeNode("Mujer negro");
Actors.add(actors_mujer_negro);
DefaultMutableTreeNode actors_woman=new DefaultMutableTreeNode("Woman");
Actors.add(actors_woman);
DefaultMutableTreeNode actors_young_woman=new DefaultMutableTreeNode("Young/Woman");
Actors.add(actors_young_woman);
//----------------CREACION DE LAS CLASES DE COLLISIONS---------------
//_____ Elimino un poco del codigo del arbol que es mas llenado del mismo
//-----------INDIVIUDOS DE OBJECTS------------------
//TODO: Fin de la poblacion del arbol


jtf = new JTextField("",20);
jtf.setPreferredSize(new java.awt.Dimension(500, 290));
//TODO: creación de tabla-----------------------------
{

Object[][] _datos={};

String[] _columnas = {"Nombre", "Propiedades"};
final JTable table = new JTable(_datos,_columnas);
table.setPreferredScrollableViewportSize(new Dimension(300, 70));

//Creamos un JscrollPane y le agregamos la JTable
JScrollPane scrollPane = new JScrollPane(table);
getContentPane().add(scrollPane, BorderLayout.EAST);

}
//----------------------------------
{
jtf = new JTextField();
getContentPane().add(jtf, BorderLayout.SOUTH);
}
//TODO: evento mouse-----------------------------------
jTree1.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent me) {
doMouseClicked(me);
}
});
}

void doMouseClicked(MouseEvent me) {
TreePath tp = jTree1.getPathForLocation(me.getX(), me.getY());
if (tp != null){
jtf.setText(tp.toString());
OWLIndividual _actor= owlModel.getOWLIndividual(tp.toString());
Collection _cProp= _actor.getRDFProperties();
for(java.util.Iterator _cr=_cProp.iterator();_cr.hasNext();){
contador=contador+1;
RDFResource _aProp = (RDFResource) _cr.next();
RDFProperty _currProp = owlModel.getRDFProperty(_aProp.getName());
RDFSClass _type = _currProp.getRDFType();
//--------
Collection _propiedades=_actor.getPropertyValueLiterals(_curr Prop);
//String temp_1 = "";
for(java.util.Iterator _x=_propiedades.iterator(); _x.hasNext();){
RDFSLiteral _valor=(RDFSLiteral)_x.next();
String _cadena = _valor.getString();
temp_1 =_cadena + ", ";
//jTable1.set

if (_type != null){
System.out.println(_type.getName());
}
}//fin del segundo for

}//fin del for

}//fin del if

//}
else
jtf.setText("");


}
}

Quiero extraer datos de tem_1 y mandarlos a imprimir en la tabla O.o pero no hayo como

Última edición por Zent; 24/06/2009 a las 16:18