Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Commit

Permalink
Definir la ventana de reporte + ejemplo
Browse files Browse the repository at this point in the history
  • Loading branch information
Laifsyn committed Jun 18, 2024
1 parent b44f446 commit 9b6e84d
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.utp.clsHerramientas.pry6_trabajo_final.ui;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

Expand All @@ -9,14 +11,17 @@
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.time.LocalDate;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;

public final class Reporte1 {
public static final DateTimeFormatter FORMATTER = DateTimeFormatter
.ofPattern("dddd 'de dd 'de MMMM 'de yyyy, zzzz");
.ofPattern("EEEE dd 'de' MMMM 'de' yyyy HH:mm:ss a, zzzz",
new Locale.Builder().setLanguage("es").setRegion("PA").build());
final Cliente cliente;
final Factura[] facturas;
public final JButton ok = new JButton("OK");

public Reporte1(Cliente cliente, Factura[] facturas) {
this.cliente = cliente;
Expand All @@ -29,7 +34,7 @@ public JPanel as_panel() {
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 4;
gbc.fill = GridBagConstraints.BOTH;
gbc.fill = GridBagConstraints.VERTICAL;
panel.add(into_header_label("UNIVERSIDAD TECNOLÓGICA DE PANAMÁ"), gbc);
gbc.gridy = 1;
panel.add(into_header_label("CENTRO REGIONAL DE CHIRIQUÍ"), gbc);
Expand All @@ -38,13 +43,9 @@ public JPanel as_panel() {
gbc.gridy = 3;
panel.add(into_header_label("CARRERA: LICENCIATURA EN INGENIERÍA DE SISTEMAS COMPUTACIONALES"), gbc);
gbc.gridy = 4;
panel.add(into_header_label("GRUPO:"), gbc);
panel.add(into_header_label("GRUPO: 2IL701"), gbc);
gbc.gridy = 5;
{
var empty_panel = new JPanel();
empty_panel.setPreferredSize(new Dimension(50, 50));
panel.add(empty_panel, gbc);
}
panel.add(empty_panel(), gbc);
gbc.gridy = 6;
panel.add(into_header_label("ANÁLISIS DE CUENTAS POR COBRAR POR CLIENTE"), gbc);
gbc.gridy = 7;
Expand All @@ -58,23 +59,39 @@ public JPanel as_panel() {

gbc.gridy = 8;
gbc.gridx = 0;
panel.add(into_label("FECHA: " + FORMATTER.format(LocalDate.now())), gbc);
gbc.gridwidth = 4;
// panel.add(into_label("FECHA: " + FORMATTER.format(LocalDate.now())), gbc);
panel.add(into_label("FECHA: " + FORMATTER.format(ZonedDateTime.now())), gbc);

gbc.gridy = 9;
gbc.gridx = 0;
gbc.gridwidth = 2;

panel.add(into_label("Codigo de Cliente: <html><p style=\"background-color:MediumBlue;>"
+ cliente.nombre_completo() + "</p></html>"), gbc);
gbc.gridx = 1;
panel.add(into_label("nombre: " + cliente.nombre_completo()), gbc);
panel.add(into_label("<html><a>Codigo de Cliente: <a style=\"color:Blue;\">"
+ cliente.codigo() + "</a></a></html>"), gbc);
gbc.gridwidth = 2;
gbc.gridx = 2;
panel.add(into_label(" Nombre: " + cliente.nombre_completo()), gbc);

Table tabla = new Table(facturas, cliente);
gbc.gridwidth = 2;
gbc.gridy = 10;
gbc.gridx = 0;
gbc.gridwidth = 4;
gbc.fill = GridBagConstraints.BOTH;
panel.add(this.empty_panel(), gbc);
gbc.gridy = 11;
panel.add(tabla.as_panel(), gbc);
return panel;
JPanel final_panel = new JPanel();
final_panel.setLayout(new BoxLayout(final_panel, BoxLayout.Y_AXIS));
final_panel.add(panel);
final_panel.add(this.empty_panel());
final_panel.add(ok);
return final_panel;
}

public void add_ok_action(Runnable action) {
ok.addActionListener(e -> action.run());
}

JLabel into_header_label(String text) {
Expand All @@ -90,4 +107,21 @@ JLabel into_label(String text) {
label.setForeground(UI.Black);
return label;
}

JPanel empty_panel() {
var empty_panel = new JPanel();
empty_panel.setPreferredSize(new Dimension(50, 20));
return empty_panel;
}

public static void main(String[] args) {
Cliente[] cliente = Cliente.cargar_clientes();
Factura[] facturas = Factura.cargar_facturas();
Reporte1 reporte = new Reporte1(cliente[3], facturas);
reporte.add_ok_action(() -> {
System.out.println("OK! Exiting....");
System.exit(0);
});
UI.show(reporte.as_panel());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import java.awt.Color;
import java.awt.Font;

import javax.swing.JFrame;
import javax.swing.JPanel;

public final class UI {
public static final Color Black = Color.BLACK;
public static final Color DarkCyan = new Color(0, 102, 204);
Expand All @@ -13,6 +16,14 @@ public final class UI {
public static class ProjFont {
public static final Font HEADER = new Font(Font.MONOSPACED, Font.BOLD, 14);
public static final Font NORMAL = new Font(Font.MONOSPACED, Font.PLAIN, 12);

}

public static void show(JPanel panel) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(panel);
frame.pack();
frame.setVisible(true);

}
}

0 comments on commit 9b6e84d

Please sign in to comment.