
Traer un dato desde una ventana nueva a la anterior
Publicado por Nerina (1 intervención) el 21/10/2015 13:55:49
Hola programadores!
Estoy haciendo un sistema, y estoy estancada en un problema, quiza de muy simple soluciòn, pero con la que no puedo dar.
El problema es el siguiente, tengo que cargar un proyecto, y ese proyecto va unido a una nota de pedido, para esto en la interfaz de carga de proyecto o tarea, hago un boton buscar nota de pedido, donde en una tabla muestro las notas que existen, y al seleccionar una y dar click a agregar quiero volver a mi ventana anterior de proyectos y que me muestre esa nota seleccionada en un jTextField... NO SE COMO LOGRARLO. dejo el codigo de tareas y de buscar!
Auxilio!
En las imagenes estan las dos clases como para que vean como es la cosa.
Graciassssss
package Interfaz;
public class CargarTareas extends javax.swing.JFrame {
/**
* Creates new form CargarTareas
*/
public CargarTareas() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {...//No los subo porq se genera automatico }// </editor-fold>
private void jRadioButton5ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
obser.setEnabled(true);
}
private void botonCargarTareaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
jTextField1.setEnabled(true);
jTextField2.setEnabled(true);
jTextField3.setEnabled(true);
jTextField4.setEnabled(true);
jTextField5.setEnabled(true);
}
private void botonCancelarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:.
dispose();
}
private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
BuscarNotasPedido notas = new BuscarNotasPedido();
private void botonBuscarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
notas.setVisible(true);
this.continuarCarga();
}
private void continuarCarga(){
notaPedido.setText("hola");
System.out.println("Se recibio "+notas.getNotaSeleccionada());
}
// Variables declaration - do not modify
private javax.swing.JButton botonBuscar;
private javax.swing.JButton botonCancelar;
private javax.swing.JButton botonCargarTarea;
private javax.swing.ButtonGroup grupoTareas;
private javax.swing.JCheckBox jCheckBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JRadioButton jRadioButton1;
private javax.swing.JRadioButton jRadioButton2;
private javax.swing.JRadioButton jRadioButton3;
private javax.swing.JRadioButton jRadioButton4;
private javax.swing.JRadioButton jRadioButton5;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
private javax.swing.JTextField jTextField5;
private javax.swing.JTextField notaPedido;
private javax.swing.JTextField obser;
// End of variables declaration
}
ackage Interfaz;
import javax.swing.JOptionPane;
public class BuscarNotasPedido extends javax.swing.JFrame {
/**
* Creates new form BuscarNotasPedido
*/
public BuscarNotasPedido() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {//no lo agrego porque se genera automatico }// </editor-fold>
public String notaSeleccionada;
private void botonAgregarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String notaPedido = " Nº pedido: ";
int i = -1;
i = jTable1.getSelectedRow();
if (i == -1) {
JOptionPane.showMessageDialog(null, "Seleccione una fila");
i = jTable1.getSelectedRow();
}
this.setNotaSeleccionada(jTable1.getValueAt(i, 1) + ", Cliente: " + (String) jTable1.getValueAt(i, 2));
System.out.println("Nota seleccionada: " + getNotaSeleccionada());
this.setVisible(false);
}
public void setNotaSeleccionada(String nota){
notaSeleccionada=nota;
}
public String getNotaSeleccionada(){
return this.notaSeleccionada;
}
public String aaa() {//ver como setear el textfield
String a = "";
return a;
}
private void botonCancelarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
dispose();
}
/**
* @param args the command line arguments
*/
// Variables declaration - do not modify
private javax.swing.JButton botonAgregar;
private javax.swing.JButton botonCancelar;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
// End of variables declaration
}


Estoy haciendo un sistema, y estoy estancada en un problema, quiza de muy simple soluciòn, pero con la que no puedo dar.
El problema es el siguiente, tengo que cargar un proyecto, y ese proyecto va unido a una nota de pedido, para esto en la interfaz de carga de proyecto o tarea, hago un boton buscar nota de pedido, donde en una tabla muestro las notas que existen, y al seleccionar una y dar click a agregar quiero volver a mi ventana anterior de proyectos y que me muestre esa nota seleccionada en un jTextField... NO SE COMO LOGRARLO. dejo el codigo de tareas y de buscar!
Auxilio!
En las imagenes estan las dos clases como para que vean como es la cosa.
Graciassssss
package Interfaz;
public class CargarTareas extends javax.swing.JFrame {
/**
* Creates new form CargarTareas
*/
public CargarTareas() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {...//No los subo porq se genera automatico }// </editor-fold>
private void jRadioButton5ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
obser.setEnabled(true);
}
private void botonCargarTareaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
jTextField1.setEnabled(true);
jTextField2.setEnabled(true);
jTextField3.setEnabled(true);
jTextField4.setEnabled(true);
jTextField5.setEnabled(true);
}
private void botonCancelarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:.
dispose();
}
private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
BuscarNotasPedido notas = new BuscarNotasPedido();
private void botonBuscarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
notas.setVisible(true);
this.continuarCarga();
}
private void continuarCarga(){
notaPedido.setText("hola");
System.out.println("Se recibio "+notas.getNotaSeleccionada());
}
// Variables declaration - do not modify
private javax.swing.JButton botonBuscar;
private javax.swing.JButton botonCancelar;
private javax.swing.JButton botonCargarTarea;
private javax.swing.ButtonGroup grupoTareas;
private javax.swing.JCheckBox jCheckBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JRadioButton jRadioButton1;
private javax.swing.JRadioButton jRadioButton2;
private javax.swing.JRadioButton jRadioButton3;
private javax.swing.JRadioButton jRadioButton4;
private javax.swing.JRadioButton jRadioButton5;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
private javax.swing.JTextField jTextField5;
private javax.swing.JTextField notaPedido;
private javax.swing.JTextField obser;
// End of variables declaration
}
ackage Interfaz;
import javax.swing.JOptionPane;
public class BuscarNotasPedido extends javax.swing.JFrame {
/**
* Creates new form BuscarNotasPedido
*/
public BuscarNotasPedido() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {//no lo agrego porque se genera automatico }// </editor-fold>
public String notaSeleccionada;
private void botonAgregarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String notaPedido = " Nº pedido: ";
int i = -1;
i = jTable1.getSelectedRow();
if (i == -1) {
JOptionPane.showMessageDialog(null, "Seleccione una fila");
i = jTable1.getSelectedRow();
}
this.setNotaSeleccionada(jTable1.getValueAt(i, 1) + ", Cliente: " + (String) jTable1.getValueAt(i, 2));
System.out.println("Nota seleccionada: " + getNotaSeleccionada());
this.setVisible(false);
}
public void setNotaSeleccionada(String nota){
notaSeleccionada=nota;
}
public String getNotaSeleccionada(){
return this.notaSeleccionada;
}
public String aaa() {//ver como setear el textfield
String a = "";
return a;
}
private void botonCancelarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
dispose();
}
/**
* @param args the command line arguments
*/
// Variables declaration - do not modify
private javax.swing.JButton botonAgregar;
private javax.swing.JButton botonCancelar;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
// End of variables declaration
}
Valora esta pregunta


0