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

Commit

Permalink
Improve user feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Laifsyn committed Jun 20, 2024
1 parent 51400e7 commit 088f5a2
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/main/java/com/utp/clsHerramientas/pry6_trabajo_final/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import javax.swing.JTextArea;
import javax.swing.JTextField;

import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
Expand Down Expand Up @@ -43,6 +44,7 @@ class App {
public final JFrame frame = new JFrame("Trabajo Final - Arreglo de Objetos");
final JButton btn_mostrar_factura = new JButton("Mostrar Factura");
final JTextField txt_buscar = new JTextField(35);
final JLabel user_hint = new JLabel();
boolean last_buscar_result = true;

void run() {
Expand All @@ -66,7 +68,7 @@ JPanel content_pane() {
gbc.gridx = 0;
gbc.gridy = 0;
gbc.insets = new Insets(2, 0, 2, 0);
panel.add(new JLabel("Ingrese el Codigo de Cliente"), gbc);
panel.add(user_hint, gbc);

gbc.gridy = 1;
panel.add(txt_buscar, gbc);
Expand Down Expand Up @@ -123,12 +125,21 @@ case Buscar(String codigo) -> {
}
if (cliente == null) {
btn_mostrar_factura.setEnabled(false);
if (txt_buscar.getText().isEmpty()) {
user_hint.setText("Ingrese el Codigo de Cliente");
user_hint.setForeground(Color.BLACK);
} else {
user_hint.setText("Código no se reconoce");
user_hint.setForeground(Color.RED);
}
if (last_buscar_result) {
System.out.println("Cliente: `" + codigo + "` no existe");
last_buscar_result = false;
}
return;
}
user_hint.setText("Codigo Reconocido");
user_hint.setForeground(UI.DarkGreen);
btn_mostrar_factura.setEnabled(true);
}
case MostrarFactura() -> {
Expand All @@ -141,14 +152,15 @@ case MostrarFactura() -> {
}
// reiniciar la búsqueda
txt_buscar.setText("");
btn_mostrar_factura.setEnabled(false);
send_command(new Buscar(""));
Reporte reporte = new Reporte(Cliente, facturas);

var reporte1 = UI.show(reporte.as_reporte_1());
var reporte2 = UI.show(reporte.as_reporte_2());
String titulo = "Reporte de Facturas - Cliente: " + Cliente.nombre_completo();
reporte1.setTitle(titulo);
reporte2.setTitle(titulo);
reporte1.toFront();
reporte.add_ok_action(new Runnable() {
@Override
public void run() {
Expand Down

0 comments on commit 088f5a2

Please sign in to comment.