Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/efrain-svg/Potes_Freddy_ProgInterfacesG_U3/llms.txt

Use this file to discover all available pages before exploring further.

ventana is the application’s sole window and its main entry point. As a JFrame subclass it owns every Swing component in the UI: the tabbed layout, the contact form, the action toolbar, the filter bar, the sortable table, the statistics cards, and the two custom chart panels. All fields are declared public so the controller can register listeners and read or write values directly — a deliberate trade-off that avoids getter/setter boilerplate in a single-window desktop app.

Class declaration

src/vista/ventana.java
public class ventana extends JFrame
ventana extends JFrame directly and is instantiated once from main(). There is no separate frame configuration class; all window properties and child component construction happen inside the constructor.

main() entry point

src/vista/ventana.java
public static void main(String[] args) {
    ThemeManager.setupLookAndFeel();

    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                ventana frame = new ventana();
                frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}
ThemeManager.setupLookAndFeel() is called before invokeLater so that FlatLaf is fully configured before any Swing component is constructed. The window is then created and made visible on the EDT.

Constructor

src/vista/ventana.java
public ventana() {
    setTitle("Gestion de Contactos");
    setIconImage(cargarIconoVentana());
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 1180, 740);
    setMinimumSize(new Dimension(1100, 700));
    setLocationRelativeTo(null);

    contentPane = new JPanel(new BorderLayout(10, 10));
    contentPane.setBorder(BorderFactory.createEmptyBorder(PADDING, PADDING, PADDING, PADDING));
    contentPane.setBackground(ThemeManager.BACKGROUND);
    setContentPane(contentPane);

    tabs = new JTabbedPane();
    tabs.setFont(fontBase(13, Font.BOLD));
    tabs.setBackground(ThemeManager.BACKGROUND);
    contentPane.add(tabs, BorderLayout.CENTER);

    construirTabContactos();
    construirTabEstadisticas();

    new logica_ventana(this);
}
PropertyValue
Initial size1180 × 740 px
Minimum size1100 × 700 px
Centered on screensetLocationRelativeTo(null)
Close operationEXIT_ON_CLOSE
Root backgroundThemeManager.BACKGROUND (#EEF2F7)
The last line — new logica_ventana(this) — wires the controller. The controller’s return value is intentionally discarded; it keeps itself alive through listener registrations.

Public fields

The view intentionally exposes public fields so the controller can register listeners and update values without getter/setter boilerplate — a pragmatic approach for single-window Swing desktop applications.

Form inputs

FieldTypeDescription
txt_nombresJTextFieldContact name input
txt_telefonoJTextFieldPhone number input
txt_emailJTextFieldEmail address input
txt_buscarJTextFieldLive search / filter field
chb_favoritoJCheckBoxFavorite toggle in the form
cmb_categoriaJComboBox<String>Category selector (Choose / Family / Friends / Work)
cmb_filtro_categoriaJComboBox<String>Category filter above the table (All / Family / Friends / Work)
cmb_idiomaJComboBox<String>Language selector (ES / EN / PT)

Action buttons

FieldTypeStyle
btn_addJButtonPrimary (blue, ThemeManager.PRIMARY)
btn_modificarJButtonSecondary (light gray)
btn_eliminarJButtonDanger (red #DC2626)
btn_exportarJButtonSecondary (light gray)

Table

FieldTypeDescription
tbl_contactosJTable5-column contacts table — Name, Phone, Email, Category, Fav
modeloTablaDefaultTableModelNon-editable model; column 4 typed as Boolean.class for the star renderer

Status bar

FieldTypeDescription
pgb_cargaJProgressBarShows indeterminate progress during async operations; fixed width 150 × 8 px
lbl_estadoJLabelStatus text in the bottom-left corner; colored ThemeManager.SUCCESS

Statistics labels

FieldTypeDescription
lbl_totalJLabelDisplays total contact count
lbl_favoritosJLabelDisplays favorite contact count
lbl_familiaJLabelDisplays family category count
lbl_amigosJLabelDisplays friends category count
lbl_trabajoJLabelDisplays work category count
lbl_actualizacionJLabelLast-updated timestamp line

Statistics card title labels (i18n targets)

FieldDescription
ttl_totalTitle label above lbl_total
ttl_favoritosTitle label above lbl_favoritos
ttl_familiaTitle label above lbl_familia
ttl_amigosTitle label above lbl_amigos
ttl_trabajoTitle label above lbl_trabajo

Charts

FieldTypeDescription
pnl_chart_barrasBarChartPanelCustom bar chart showing contacts per category
pnl_chart_pastelPieChartPanelCustom pie chart showing distribution across the three categories

Context menu

FieldTypeDescription
menuContextualJPopupMenuRight-click popup on the table
mnu_editarJMenuItemLoad selected contact into the form for editing
mnu_eliminarJMenuItemDelete selected contact
mnu_favoritoJMenuItemToggle favorite status
mnu_exportarJMenuItemExport currently visible rows to CSV

Tab header labels

FieldDescription
lbl_tab_contactosSection heading inside the Contacts tab (translated by controller)
lbl_tab_estadisticasSection heading inside the Statistics tab

Form row labels (i18n targets)

lbl_nombre, lbl_telefono, lbl_email, lbl_categoria, lbl_filtro, lbl_categoria_filtro, lbl_idioma — all translated by aplicarIdioma() in the controller.

Tab layout

Contacts tab (construirTabContactos)

The tab uses BorderLayout(SECTION_GAP, SECTION_GAP) as its root:
┌─────────────────────────────────────────────────────┐  NORTH
│  Section header: "Detalles"          [Language: ES▾] │
├─────────────────────────────────────────────────────┤  CENTER (GridBagLayout rows)
│  Row 0 — Form panel (GridBagLayout)                  │
│  [Name ___________] [Phone __________] [Email ______]│
│  [Category ▾]       [☐ Favorite]                     │
├─────────────────────────────────────────────────────┤
│  Row 1 — Action bar (FlowLayout RIGHT)               │
│            [+ Add] [Edit] [Export CSV] [Delete]      │
├─────────────────────────────────────────────────────┤
│  Row 2 — Filter bar (GridBagLayout)                  │
│  [🔍] [Search ____________________] [Category ▾]    │
├─────────────────────────────────────────────────────┤
│  Row 3 — Table panel (BorderLayout, weighty=1.0)     │
│  ┌──────────────────────────────────────────────┐   │
│  │  Name │ Phone │ Email │ Category │ ★         │   │
│  │  ...  │  ...  │  ...  │  ...     │ ☆         │   │
│  └──────────────────────────────────────────────┘   │
├─────────────────────────────────────────────────────┤  SOUTH
│  • Ready                              [=========]    │
└─────────────────────────────────────────────────────┘
  • The form panel sits inside a card (SURFACE background, CARD_BORDER border, 10 px padding).
  • The table is wrapped in a JScrollPane with a ThemeManager.BORDER line border.
  • The status bar uses ThemeManager.SURFACE background; the progress bar is pinned to BorderLayout.EAST.

Statistics tab (construirTabEstadisticas)

┌─────────────────────────────────────────────────────┐  NORTH
│                             Last updated: DD/MM/YYYY │
├──────┬──────────┬─────────┬─────────┬───────────────┤  CENTER row 0
│Total │Favorites │ Family  │ Friends │     Work      │  GridLayout(1,5,16,0)
│  42  │   12     │    8    │   15    │      19       │
├───────────────────────┬─────────────────────────────┤  CENTER row 1
│    Bar Chart          │        Pie Chart             │  GridLayout(1,2,16,0)
│  (BarChartPanel)      │     (PieChartPanel)          │
└───────────────────────┴─────────────────────────────┘
Each stat card is built by crearTarjeta(titulo, valor) using a BoxLayout Y_AXIS with vertical glue for centering. The title label uses ThemeManager.TEXT_SECONDARY at 14 Bold; the value label uses ThemeManager.PRIMARY at 28 Bold.

ThemeManager colors

ConstantHexUsage
PRIMARY#2563EBButton backgrounds, progress bar, stat value labels, tab underline
BACKGROUND#EEF2F7Root content pane, tab pane, panels
SURFACE#FFFFFFCards, table background, status bar
TEXT_PRIMARY#1F2937Main text, table foreground
TEXT_SECONDARY#4B5563Form labels, stat card titles, secondary text
SUCCESS#198754Status bar label color
BORDER#DEE2E6Card borders, table scroll pane border
FAVORITE#FFC107Reserved for favorite star highlight
ThemeManager.setupLookAndFeel() also applies UI defaults to FlatLaf via UIManager.put(...) calls — including rounded corners (Component.arc = 12), table alternating row colors, and custom tab insets. These affect the entire application without needing per-component styling.

Build docs developers (and LLMs) love