tengo dos ventanas dos jframes vale. en un jframe tengo un textarea que es donde quiero poner la cédula o identificación de una persona.... en el otro jframe tengo una tabla con la información de los pacientes lo que quiero es buscar en ese jframe el paciente correcto y desde ese jframe quiero pasar la identificación al otro jframe y quiero que se ponga en el textarea que he creado. mi jtextarea es public y mi jtable también es public.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package sismedvista;
import cliente.BusquedaPaciente;
import javax.swing.JOptionPane;
import sismedvista.pacienteEsc;
/**
*
* @author laptop
*/
public class pacienteEsc extends javax.swing.JFrame {
String paciente = "";
public pacienteEsc() {
initComponents();
cargarTabla("");
}
void cargarTabla(String cad) {
BusquedaPaciente c = new BusquedaPaciente();
c.CargarTabla(jTable1, cad);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel2 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
setTitle("Buscar Paciente");
setLocation(new java.awt.Point(480, 200));
setPreferredSize(new java.awt.Dimension(415, 350));
getContentPane().setLayout(null);
jLabel2.setFont(new java.awt.Font("Roboto", 0, 11)); // NOI18N
jLabel2.setText("Diguite la cedula del paciente:");
getContentPane().add(jLabel2);
jLabel2.setBounds(10, 10, 380, 14);
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jTable1MouseClicked(evt);
}
});
jScrollPane1.setViewportView(jTable1);
getContentPane().add(jScrollPane1);
jScrollPane1.setBounds(10, 70, 380, 220);
jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
}
});
jTextField1.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
jTextField1KeyReleased(evt);
}
});
getContentPane().add(jTextField1);
jTextField1.setBounds(10, 30, 170, 30);
getContentPane().add(jTextField2);
jTextField2.setBounds(210, 30, 150, 30);
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imgs/fondo-blanco.jpg"))); // NOI18N
getContentPane().add(jLabel1);
jLabel1.setBounds(0, 0, 400, 340);
pack();
}// </editor-fold>
private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jTextField1KeyReleased(java.awt.event.KeyEvent evt) {
cargarTabla(jTextField1.getText());
}
private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {
int filaseleccionada = jTable1.getSelectedRow();
String cedula = (String) jTable1.getValueAt(filaseleccionada, 0);
//JOptionPane.showMessageDialog(null,"Tenemos seleccionado algo "+ cedula,"Mensaje",JOptionPane.INFORMATION_MESSAGE);
examFisi.jTextArea6.setText(cedula);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(pacienteEsc.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(pacienteEsc.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(pacienteEsc.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(pacienteEsc.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new pacienteEsc().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JScrollPane jScrollPane1;
public javax.swing.JTable jTable1;
private javax.swing.JTextField jTextField1;
public static javax.swing.JTextField jTextField2;
// End of variables declaration
}
examFisi frame = new examFisi();
con esto creas una nueva instacia por lo que el jframe original no se va a enterar