Foro de Java y C++ de Chuidiang

Este foro se mueve a Foro de Java y C++

Foro de Java y C++ de Chuidiang
COMO REUTILIZAR CLASE EN JAVA (BOTONES)
* E-mail:
* Password:
Registrarse Presentación Miembros Imágenes
¿Has olvidado tu Password?

Lista de mensajes
Autor Mensaje
Francisco José
 
Mensajes: 2
Registrado: Febrero/2008
Estado: Off-line
Grupo: Nuevo usuario
 
 
  Re: COMO REUTILIZAR CLASE EN JAVA (BOTONES) 08/Febrero/2008 - 07:54

Buenas Luis. Yo me he planteado con el mismo problema lo único que yo utilizo un JToolBar en vez de un JPanel, pero bueno, al fin y al cabo son contenedores. Yo ahora mismo tengo implementado en cada JInternalFrame los botones de navegación correspondientes, primero, último, nuevo, borrar, modificar, buscar .... pero a la hora de estandalizarlo como tu dices, me encontré con una serie de problemas. Ahora mismo estoy trabajando para estandarizar mi programa, cuando lo consiga, te podré ayudar con lo tuyo, 1saludo.
Francisco José
 
Mensajes: 2
Registrado: Febrero/2008
Estado: Off-line
Grupo: Nuevo usuario
 
 
  Re: COMO REUTILIZAR CLASE EN JAVA (BOTONES) 08/Febrero/2008 - 07:54

Buenas Luis. Yo me he planteado con el mismo problema lo único que yo utilizo un JToolBar en vez de un JPanel, pero bueno, al fin y al cabo son contenedores. Yo ahora mismo tengo implementado en cada JInternalFrame los botones de navegación correspondientes, primero, último, nuevo, borrar, modificar, buscar .... pero a la hora de estandalizarlo como tu dices, me encontré con una serie de problemas. Ahora mismo estoy trabajando para estandarizar mi programa, cuando lo consiga, te podré ayudar con lo tuyo, 1saludo.
Luis Leon
 
Mensajes: 9
Registrado: Enero/2008
Estado: Off-line
Grupo: Nuevo usuario
 
 
  COMO REUTILIZAR CLASE EN JAVA (BOTONES) 29/Enero/2008 - 16:34

HOLA AMIGOS, TENGO UN INCONVENIENTE Y ESPERO QUE ME PUEDAN AYUDAR. DESEO HACER VENTANAS DE MANTENIMIENTO DE DIFERENTES TABLAS EN UN SISTEMA, PERO QUIERO VER LA POSIBILIDAD DE REUTILIZAR EL CODIGO  Y APROVECHAR ESE POTENCIAL DE JAVA. LA IDEA ES UTILIZAR POR EJEMPLO LOS MISMOS BOTONES DE MANTENIMIENTO PARA TODAS LAS VENTANAS.

PARA ESTO, CREE UN JPANEL CON TODOS LOS BOTONES CORRESPONDIENTES Y EN EL CONSTRUCTOT DE ESTE JPANEL, RECIBO COMO PARAMETROS LAS ACCIONES CORRESPONDIENTES A CADA BOTON DE LA SIGUIENTE MANERA:

=======================================================================================

    public Botones(
            Action actionPrimero,
            Action actionAnterior,
            Action actionSiguiente,
            Action actionUltimo,
            Action actionNuevo,
            Action actionModificar,
            Action actionEliminar,
            Action actionBuscar,
            Action actionGuardar,
            Action actionCancelar,          
            Action actionSalir){
        this.actionPrimero=actionPrimero;
        this.actionAnterior=actionAnterior;
        this.actionSiguiente=actionSiguiente;
        this.actionUltimo=actionUltimo;
        this.actionNuevo=actionNuevo;
        this.actionModificar=actionModificar;
        this.actionEliminar=actionEliminar;
        this.actionBuscar=actionBuscar;
        this.actionGuardar=actionGuardar;
        this.actionCancelar=actionCancelar;       
        this.actionSalir=actionSalir;
        initComponents();
    }

=======================================================================================

Y LUEGO EN EL initComponents(), COLOQUE EL SIGUIENTE CODIGO:

=======================================================================================

 jButton1 = new javax.swing.JButton(actionPrimero);
 jButton2 = new javax.swing.JButton(actionAnterior);
 jButton3 = new javax.swing.JButton(actionSiguiente);
 jButton4 = new javax.swing.JButton(actionUltimo);
 jButton5 = new javax.swing.JButton(actionNuevo);
 jButton6 = new javax.swing.JButton(actionModificar);
 jButton7 = new javax.swing.JButton(actionEliminar);
 jButton8 = new javax.swing.JButton(actionBuscar);
 jButton9 = new javax.swing.JButton(actionGuardar);
 jButton10 = new javax.swing.JButton(actionCancelar);
 jButton11 = new javax.swing.JButton(actionSalir);

=======================================================================================

EN LA VENTANA DESDE DONDE VOY A UTILIZAR LOS BOTONES INSERTO EL JPANEL Y EN EL CONSTRUCTOR COLOCO EL SIGUIENTE CODIGO PARA ARMAR LAS ACCIONES QUE LUEGO ENVIARE AL RESPECTIVO JPANEL:

=======================================================================================

        conexion = FrmPrincipal.getConexionPrincipal().Consulta("SELECT * FROM MAEPAIS ORDER BY CODPAIS");
        //*** Iniciar valores de variables para enviar como Parametros a Botones ***
        actionPrimero=new ActionPrimero ("<<", null, "Ir al Primer Registro", null, this, conexion);
        actionAnterior=new ActionAnterior ("<", null, "Ir al Anterior Registro", null, this, conexion);
        actionSiguiente=new ActionSiguiente (">", null, "Ir al Siguiente Registro", null, this, conexion);
        actionUltimo=new ActionUltimo (">>", null, "Ir al Ultimo Registro", null, this, conexion);
        actionNuevo=new ActionNuevo ("Nuevo", null, "Crear Nuevo Registro", new Integer(KeyEvent.VK_N), this);
        actionModificar=new ActionModificar ("Modificar", null, "Modificar Registro", new Integer(KeyEvent.VK_M), this);
        actionEliminar=new ActionEliminar ("Eliminar", null, "Eliminar Registro", new Integer(KeyEvent.VK_E), this);
        actionBuscar=new ActionBuscar ("Buscar", null, "Buscar Registros", new Integer(KeyEvent.VK_B), this);
        actionGuardar=new ActionGuardar ("Guardar", null, "Guardar Registro", new Integer(KeyEvent.VK_G), this);
        actionCancelar=new ActionCancelar ("Cancelar", null, "Cancela Registro", new Integer(KeyEvent.VK_C), this);
        actionSalir=new ActionSalir("Salir", null, "Salir de la Ventana", new Integer(KeyEvent.VK_S), this);
        //**************************************************************************

===========================================================================================

        botones1 = new com.automundial.utilidades.Botones(
            actionPrimero,
            actionAnterior,
            actionSiguiente,
            actionUltimo,
            actionNuevo,
            actionModificar,
            actionEliminar,
            actionBuscar,
            actionGuardar,
            actionCancelar,
            actionSalir);

===========================================================================================

PREVIAMENTE DEFINI UNA CLASE QUE TENDRA LAS ACCIONES POR CADA BOTON DE LA SIGUIENTE MANERA:

===========================================================================================

public class ActionPrimero extends AbstractAction  {

    private Clase009 frame;
    private ResultSet conexion;
   
    /** Creates a new instance of ActionPrimero */
    public ActionPrimero(
            String text,
            ImageIcon icon,
            String desc,
            Integer mnemonic,
            JInternalFrame frame,
            ResultSet conexion) {
        super (text, icon);
        putValue(SHORT_DESCRIPTION, desc);
        putValue(MNEMONIC_KEY, mnemonic);
        this.frame=(Clase009) frame;
        this.conexion=conexion;
    }

    public void actionPerformed(ActionEvent e) {
        try {
            conexion.first();   
            System.out.println("Fui al Primero");
            frame.getDatos11().getJTextField1().setText(conexion.getString(1));
            frame.getDatos11().getJTextField1().setText(conexion.getString(2));
//            frame.MostrarDatos();
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
    }   
}

=======================================================================================

EL PROBLEMA ES QUE COMO VOY A TRABAJAR CON DATOS, COMO PUEDO HACER EL MANEJO DE LOS CAMPOS EN CADA JInternalFrame PARA ASIGNARLE EL VALOR DEL RESULTADO DE LA CONEXION ... ? .. SI EN LA ACCION COLOCO EL FRAME LOCAL DE TIPO Clase009 (QUE ES UNA DE TANTAS VENTANAS) ME FUNCIONA, PERO SOLO DESDE ESA VENTANA Y SE SUPONE QUE ESTA ACCION SE DEBERIA PODER EJECUTAR DESDE CUALQUIER JInternalFrame ... AGRADECERIA SI ALGUIEN TIENE ALGUNA IDEA DE COMO SOLUCIONAR ESTE PROBLEMITA

MUCHAS GRACIAS DE ANTEMANO,

LUIS LEON


Usuarios activos
33 usuarios activos: 0 miembros y 33 huespedes en el foro.
 Reglas de mensaje
puedes escribir nuevos temas
puedes responder a los temas
puedes adjuntar archivos
no puedes editar tus mensajes
Contactar con el Administrador del foro.

La utilización del servicio vendrá condicionada por la previa aceptación de las Condiciones Generales de Uso del Servicio.



Foro gratis creado en ForosWebGratis.com. Crea tu propio foro aquí.