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
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
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
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);
}
| Property | Value |
|---|
| Initial size | 1180 × 740 px |
| Minimum size | 1100 × 700 px |
| Centered on screen | setLocationRelativeTo(null) |
| Close operation | EXIT_ON_CLOSE |
| Root background | ThemeManager.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.
| Field | Type | Description |
|---|
txt_nombres | JTextField | Contact name input |
txt_telefono | JTextField | Phone number input |
txt_email | JTextField | Email address input |
txt_buscar | JTextField | Live search / filter field |
chb_favorito | JCheckBox | Favorite toggle in the form |
cmb_categoria | JComboBox<String> | Category selector (Choose / Family / Friends / Work) |
cmb_filtro_categoria | JComboBox<String> | Category filter above the table (All / Family / Friends / Work) |
cmb_idioma | JComboBox<String> | Language selector (ES / EN / PT) |
| Field | Type | Style |
|---|
btn_add | JButton | Primary (blue, ThemeManager.PRIMARY) |
btn_modificar | JButton | Secondary (light gray) |
btn_eliminar | JButton | Danger (red #DC2626) |
btn_exportar | JButton | Secondary (light gray) |
Table
| Field | Type | Description |
|---|
tbl_contactos | JTable | 5-column contacts table — Name, Phone, Email, Category, Fav |
modeloTabla | DefaultTableModel | Non-editable model; column 4 typed as Boolean.class for the star renderer |
Status bar
| Field | Type | Description |
|---|
pgb_carga | JProgressBar | Shows indeterminate progress during async operations; fixed width 150 × 8 px |
lbl_estado | JLabel | Status text in the bottom-left corner; colored ThemeManager.SUCCESS |
Statistics labels
| Field | Type | Description |
|---|
lbl_total | JLabel | Displays total contact count |
lbl_favoritos | JLabel | Displays favorite contact count |
lbl_familia | JLabel | Displays family category count |
lbl_amigos | JLabel | Displays friends category count |
lbl_trabajo | JLabel | Displays work category count |
lbl_actualizacion | JLabel | Last-updated timestamp line |
Statistics card title labels (i18n targets)
| Field | Description |
|---|
ttl_total | Title label above lbl_total |
ttl_favoritos | Title label above lbl_favoritos |
ttl_familia | Title label above lbl_familia |
ttl_amigos | Title label above lbl_amigos |
ttl_trabajo | Title label above lbl_trabajo |
Charts
| Field | Type | Description |
|---|
pnl_chart_barras | BarChartPanel | Custom bar chart showing contacts per category |
pnl_chart_pastel | PieChartPanel | Custom pie chart showing distribution across the three categories |
| Field | Type | Description |
|---|
menuContextual | JPopupMenu | Right-click popup on the table |
mnu_editar | JMenuItem | Load selected contact into the form for editing |
mnu_eliminar | JMenuItem | Delete selected contact |
mnu_favorito | JMenuItem | Toggle favorite status |
mnu_exportar | JMenuItem | Export currently visible rows to CSV |
| Field | Description |
|---|
lbl_tab_contactos | Section heading inside the Contacts tab (translated by controller) |
lbl_tab_estadisticas | Section heading inside the Statistics tab |
lbl_nombre, lbl_telefono, lbl_email, lbl_categoria, lbl_filtro, lbl_categoria_filtro, lbl_idioma — all translated by aplicarIdioma() in the controller.
Tab layout
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
| Constant | Hex | Usage |
|---|
PRIMARY | #2563EB | Button backgrounds, progress bar, stat value labels, tab underline |
BACKGROUND | #EEF2F7 | Root content pane, tab pane, panels |
SURFACE | #FFFFFF | Cards, table background, status bar |
TEXT_PRIMARY | #1F2937 | Main text, table foreground |
TEXT_SECONDARY | #4B5563 | Form labels, stat card titles, secondary text |
SUCCESS | #198754 | Status bar label color |
BORDER | #DEE2E6 | Card borders, table scroll pane border |
FAVORITE | #FFC107 | Reserved 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.