Foros del Web » Programación para mayores de 30 ;) » Java »

¿Como mostrar los datos en un jTable de un jDialog desde un JFrame padre?

Estas en el tema de ¿Como mostrar los datos en un jTable de un jDialog desde un JFrame padre? en el foro de Java en Foros del Web. Hola, quisiera saber como mostrar los datos que están en mi jframe padre por un jtable que se encuentra en un jdialog , las 2 ...
  #1 (permalink)  
Antiguo 21/02/2013, 12:44
 
Fecha de Ingreso: febrero-2013
Ubicación: Lima
Mensajes: 1
Antigüedad: 11 años, 1 mes
Puntos: 0
¿Como mostrar los datos en un jTable de un jDialog desde un JFrame padre?

Hola, quisiera saber como mostrar los datos que están en mi jframe padre por un jtable que se encuentra en un jdialog , las 2 clases se encuentran en el mismo.

Código jFrame:

Código Java:
Ver original
  1. public jFrame() {
  2.      initComponents();
  3.      setLocationRelativeTo(this);
  4.      gestion = new Gestion();
  5.      
  6.      
  7.   }
  8.  
  9. private void botonGuardarUnaNuevaEstampillaActionPerformed(java.awt.event.ActionEvent evt) {                                                              
  10.    
  11.          
  12.     String pais, fecha;
  13.    double valor;
  14.    long id;
  15.         try{
  16.    pais = jTextFieldPais.getText();
  17.    fecha = jTextFieldFecha.getText();
  18.    valor = Double.parseDouble(jTextFieldValor1.getText());
  19.    id = Long.parseLong(jTextFieldId.getText());
  20.    
  21.        
  22.  gestion.crearEstampilla(id, fecha, pais, valor);
  23.  
  24.         }catch(NullPointerException e){
  25.      JOptionPane.showMessageDialog(rootPane, e.getMessage());
  26.        }finally{
  27.     jTextFieldFecha.setText("");
  28.    jTextFieldPais.setText("");
  29.    jTextFieldValor1.setText("");
  30.    jTextFieldId.setText("");
  31.         }
  32.          
  33.    
  34.  
  35.     }                                                              
  36.    public Gestion getGestion(){
  37.     return gestion;
  38.    }
  39.    
  40.     private void botonVerReportesActionPerformed(java.awt.event.ActionEvent evt) {                                                
  41.        
  42.      JDialog dialog = new jDialog(this, true);
  43.      dialog.setVisible(rootPaneCheckingEnabled);
  44.     }




Código jDialog:

Código Java:
Ver original
  1. public jDialog(java.awt.Frame parent, boolean modal) {
  2.         super(parent, modal);
  3.         initComponents();
  4.         setLocationRelativeTo(this);              
  5.         visual = new jFrame();
  6.     }
  7.  private void botonMostrarInfoTablaActionPerformed(java.awt.event.ActionEvent evt) {                                                      
  8.     gestion =  visual.getGestion();
  9.      au=gestion.getCont();    
  10.      for(int i=0; i<au; i++){
  11.      
  12.         jTable1.setValueAt(gestion.getEstampillas()[i].getId(), i, 0);
  13.         jTable1.setValueAt(gestion.getEstampillas()[i].getPais(), i, 1);
  14.         jTable1.setValueAt(gestion.getEstampillas()[i].getValorF(), i, 2);
  15.         jTable1.setValueAt(gestion.getEstampillas()[i].getFecha(), i, 3);
  16.      }
  17.     }                                                    
  18.  
  19.     private void jButtonrRegresarActionPerformed(java.awt.event.ActionEvent evt) {                                                
  20.        visual.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
  21.        visual.setVisible(true);
  22.     }                                                
  23.  
  24.    
  25.    
  26.  
  27.    
  28.     public static void main(String args[]) {
  29.        
  30.         java.awt.EventQueue.invokeLater(new Runnable() {
  31.             public void run() {
  32.                 jDialog dialog = new jDialog(new javax.swing.JFrame(), true);
  33.                 dialog.addWindowListener(new java.awt.event.WindowAdapter() {
  34.                     @Override
  35.                     public void windowClosing(java.awt.event.WindowEvent e) {
  36.                         System.exit(0);
  37.                     }
  38.                 });
  39.                 dialog.setVisible(true);
  40.             }
  41.         });
  42.     }

Etiquetas: clase, jdialog, jframe, jtable, string
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:59.