jtable of internal frame to jtable of a jframe

0

I need to know how I can make the data of jtable of an internal frame go to another jtable that is in jframe in java netbeans , I'm doing a project in this language and I'm new to this.

This is part of the code:

try {
 DefaultTableModel modelo = (DefaultTableModel) recipe.tblrecipe.getModel();
 String[] datos = new String[5];
 int fil = tblinsumos.getSelectedRow();

 if (fil == -1) {
  JOptionPane.showMessageDialog(null, "NO HAS SELECCIONADO NINGUN INSUMO", "ADVERTENCIA", JOptionPane.WARNING_MESSAGE);
 } else {
  String generico = tblinsumos.getValueAt(fil, 1).toString();
  String comercial = tblinsumos.getValueAt(fil, 2).toString();
  String formafarma = tblinsumos.getValueAt(fil, 3).toString();
  String concentracion = tblinsumos.getValueAt(fil, 4).toString();
  String dosis = JOptionPane.showInputDialog("POR FAVOR INGRESA LA CANTIDAD A DISPENSAR");

  if (dosis.equals("") || dosis.equals("0")) {
   JOptionPane.showMessageDialog(this, "LA CANTIDAD DEBE SER \n SUPERIOR A 0", "ADVERTENCIA", JOptionPane.INFORMATION_MESSAGE);
  } else {
   modelo = (DefaultTableModel) recipe.tblrecipe.getModel();
   String filaelemento[] = {
    generico,
    comercial,
    formafarma,
    concentracion,
    dosis
   };
   modelo.addRow(filaelemento);
  }
 }
} catch (Exception e) {}
    
asked by Carlos Ariza 24.11.2017 в 07:10
source

1 answer

0

What you could do is fill in the String that you already have in a list like this:

 List<String> lista = new ArrayList<String>();
 lista.add(generico);
 lista.add(comercial);

Then to fill the other jTable , the variable columns can be another list that you have defined

TableModel tablaModelo = new DefaultTableModel(lista, columnas);
JTable table = new JTable(tablaModelo );
    
answered by 06.02.2018 в 18:05