Java - Enviar Datos a JFrame anterior

 
Vista:

Enviar Datos a JFrame anterior

Publicado por despotars (1 intervención) el 11/04/2014 10:12:01
Buenos Días,

Estoy trabajando con jFrames, tengo un jFrame principal, el cual llama a un segundo jFrame (jFrame2 por ejemplo). Lo que necesito es que en ese jFrame2 haya 9 botones con imágenes dentro de cada botón (HASTA AQUÍ TODO PERFECTO). Entonces cuando en el jFrame2 pulse un botón, este se cierre y envíe un string al jFram1e, el cual estará deberá quedarse esperando que el jFrame2 acabe para recibir el string y enviar una orden de JSON al servidor con ese dato.
No se si es mucho lío o si me expliqué bien.

Les paso parte del código que tengo a ver si me podéis ayudar:

////// clase jFrame1 //////

public class jFrame1 extends javax.swing.JFrame{

public JTextField JTextField1;
public JTextField JTextField2;
public JTextField JTextField3;
private JButton jButton1;

.....

}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
jFrame2 regPack = new jFrame2();
regPack.setLocationRelativeTo(null);
regPack.setVisible(true);

//AQUI QUIERO QUE EL PROGRAMA ESPERE LA RESPUESTA AL CERRAR EL JFRAME Y CONTINUE EJECUTANDOSE

....
}


////// clase jFrame2 //////

public class jFrame2 extends javax.swing.JFrame{

private JButton jButton1;
private JButton jButton2;

public jFrame2(){ }

.....

}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
//AQUI QUIERO ENVIAR UN DATO AL JFRAME ANTERIOR ANTES DE CERRAR ESTE JFRAME
this.dispose();
}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
//AQUI QUIERO ENVIAR UN DATO AL JFRAME ANTERIOR ANTES DE CERRAR ESTE JFRAME
this.dispose();
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder