> For the complete documentation index, see [llms.txt](https://educacion.gitbook.io/programacion/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://educacion.gitbook.io/programacion/ud5-entrada-e-saida-da-informacion/interfaces-graficas/exemplo-de-interface-grafica-para-xestion-de-persoas/dialogovisualizarpersona.md).

# DialogoVisualizarPersona

## DialogoVisualizarPersona

```java
package vista;

import modelo.Persona;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class DialogoVisualizarPersona extends JDialog {

    private PanelFormularioPersona panelFormulario;

    public DialogoVisualizarPersona(JFrame padre, Persona persona) {
        super(padre, "Visualizar Persona", true);

        panelFormulario = new PanelFormularioPersona(false);

        panelFormulario.cargarPersona(persona);

        add(panelFormulario, BorderLayout.CENTER);

        JButton btnCerrar = new JButton("Cerrar");
        btnCerrar.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                dispose();
            }
        });

        JPanel panelBoton = new JPanel();
        panelBoton.add(btnCerrar);
        add(panelBoton, BorderLayout.SOUTH);

        pack();
        setLocationRelativeTo(padre); 
        setResizable(false); 
    }
}

```

## VentanaPrincipal

```java
package vista;

import modelo.Persona;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;


public class VentanaPrincipal extends JFrame {

    private PanelSuperior panelSuperior;
    private PanelCentral panelCentro;
    private PanelInferior panelInferior;

    public VentanaPrincipal(){
        setTitle("Gestión de Personas");
        setSize(600,400);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setLayout(new BorderLayout());

        this.panelSuperior = new PanelSuperior();
        this.panelCentro = new PanelCentral();
        this.panelInferior = new PanelInferior();

        panelSuperior.setBackground(Color.GREEN);
        panelCentro.setBackground(Color.YELLOW);
        panelInferior.setBackground(Color.CYAN);
        //Dimensiones
        panelSuperior.setPreferredSize(new Dimension(600, 80));
        panelInferior.setPreferredSize(new Dimension(600, 60));
        //Añadimos los paneles al frame
        this.add(panelSuperior, BorderLayout.NORTH);
        this.add(panelCentro, BorderLayout.CENTER);
        this.add(panelInferior, BorderLayout.SOUTH);

        panelInferior.getBtnNuevaPersona().addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                // Abrimos el diálogo pasando la ventana y el panel central
                DialogoNuevaPersona dialogo = new DialogoNuevaPersona(VentanaPrincipal.this, panelCentro);
                dialogo.setVisible(true);
            }
        });

        panelCentro.getTabla().addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                int fila = panelCentro.getTabla().getSelectedRow();
                Persona persona = panelCentro.getPersona(fila);
                DialogoVisualizarPersona dialogo = new DialogoVisualizarPersona(VentanaPrincipal.this, persona);
                dialogo.setVisible(true);
            }
        });

        setVisible(true);
    }

}

```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://educacion.gitbook.io/programacion/ud5-entrada-e-saida-da-informacion/interfaces-graficas/exemplo-de-interface-grafica-para-xestion-de-persoas/dialogovisualizarpersona.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
