Instancia desde un intenal frame a una clase java para utilizar private´s???
Q onda compañeros como estan, tengo una duda lo q pasa tengo un proyecto de programacion orientada a objetos utlizando jframes e internal frames es sobre una agencia o mas bien un sistema de vuelo, lo q hace es q tengo en distintos internal frames (dichas ventanas tengo campos de texto etiquetas etc) y tengo varios metodos como lo q es agregar, mostrar buscar... en una clase java normal, lo q pasa es q no puedo acceder a los campos de texto ya q son PRIVATE y me comentaron q con la INSTANCIA me funciona es cierto y como lo puedo implementar? igual les dejo el codigo para explicarme mejor jajaj XD
en la ventana de IF_RESERV al agregar en los campos de texto con el boton me agrega los elementos q introdusco y ahi en ese boton mando a llamar el metodo agregar...
lo estoy programando en NETBEANS
clase del internal frame
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* IF_RESERV.java
*
* Created on 23/11/2010, 10:24:41 PM
*/
package AGENCIA_VIAJES.MENU_VUELOS.RESERVACIONES;
import AGENCIA_VIAJES.ARRAYPROYECTO;
/**
*
* @author Durc v1.0
*/
public class IF_RESERV extends javax.swing.JInternalFrame {
static ARRAYPROYECTO accion = new ARRAYPROYECTO();
/** Creates new form IF_RESERV */
public IF_RESERV() {
initComponents();
}
/** 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")
{
aqui iba todo el codigo de diseño de botones y etiquetas etc pero las borre para reducir codigo...
}
private void BT_AGREGAR_RESERVActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
accion.agregar();
}
// Variables declaration - do not modify
private javax.swing.JButton BT_AGREGAR_RESERV;
private javax.swing.JButton BT_CANCELAR;
private javax.swing.JButton BT_LIMPIAR_CAMPOS;
private javax.swing.JLabel JL_ADULT;
private javax.swing.JLabel JL_APELLIDC;
private javax.swing.JLabel JL_APELLIDE;
private javax.swing.JLabel JL_CHILD;
private javax.swing.JLabel JL_CLASS;
private javax.swing.JLabel JL_CLI;
private javax.swing.JLabel JL_DESTINO;
private javax.swing.JLabel JL_EMP;
private javax.swing.JLabel JL_FECHARETURN;
private javax.swing.JLabel JL_FECHASALIDA;
private javax.swing.JLabel JL_ID_EMPLEADO;
private javax.swing.JLabel JL_MONEY;
private javax.swing.JLabel JL_NACIONC;
private javax.swing.JLabel JL_NAMEC;
private javax.swing.JLabel JL_NAMEE;
private javax.swing.JLabel JL_ORIGEN;
private javax.swing.JLabel JL_TIPOVUEL;
private javax.swing.JLabel JL_VUEL;
private javax.swing.JTextField TX_ADULTOS;
private javax.swing.JTextField TX_APELLIDOC;
private javax.swing.JTextField TX_APELLIDOE;
private javax.swing.JTextField TX_CASH;
private javax.swing.JTextField TX_CLASEV;
private javax.swing.JTextField TX_DESTINO;
private javax.swing.JTextField TX_FECHREGR;
private javax.swing.JTextField TX_FECHSAL;
private javax.swing.JTextField TX_ID_EMPLEADO;
private javax.swing.JTextField TX_NACIONALIDAC;
private javax.swing.JTextField TX_NIÑOS;
private javax.swing.JTextField TX_NOMBREC;
private javax.swing.JTextField TX_NOMBREE;
private javax.swing.JTextField TX_ORIGEN;
private javax.swing.JTextField TX_TIPEV;
// End of variables declaration
}
<code>
clase java
<code>
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package AGENCIA_VIAJES;
import AGENCIA_VIAJES.MENU_VUELOS.RESERVACIONES.IF_RESERV;
import AGENCIA_VIAJES.MENU_VUELOS.RESERVACIONES.IF_SEE_RESERV;
import java.util.ArrayList;
/**
*
* @author Durc v1.0
*/
public class ARRAYPROYECTO {
static ArrayList<AGENTE> AG = new ArrayList<AGENTE>();
static ArrayList<COMPRADOR> CO = new ArrayList<COMPRADOR>();
static ArrayList<VUELOS> VU = new ArrayList<VUELOS>();
static ArrayList<DATOS_BOLETO> DB = new ArrayList<DATOS_BOLETO>();
static int p;
public void agregar(){
p++;
AG.add(new AGENTE());
AG.get(p).setID_EMPLEADO(IF_RESERV.TX_ID_EMPLEADO.getText());
AG.get(p).setNombre(IF_RESERV.TX_NOMBREE.getText());
AG.get(p).setApellido(IF_RESERV.TX_APELLIDOE.getText());
}}
<code>
en los textfields y esos me marca error q no puedo acceder por ejemplo en
AG.get(p).setApellido(IF_RESERV.TX_APELLIDOE.getText()); me marca error y me dice "TX_APELLIDOE has private access in AGENCIA_VIAJES.MENU_VUELOS.RESERVACIONES.IF_RESERV"
GRACIAS SI ME PUEDEN AYUDAR :D
- Inicie sesión o regístrese para enviar comentarios
Aunque tus variables sean
Aunque tus variables sean privadas, no veo donde creas métodos
getBoton()
ysetBoton()
para acceder a dichas propiedades.... así, en lugar de acceder al botón directamente, accederías por su métodoget....