Dividir el interfaz con las 2 opciones
This commit is contained in:
parent
44069205d5
commit
5295f41044
@ -12,6 +12,8 @@ import java.awt.datatransfer.Clipboard;
|
|||||||
import java.awt.datatransfer.StringSelection;
|
import java.awt.datatransfer.StringSelection;
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.Box;
|
||||||
|
import javax.swing.BoxLayout;
|
||||||
import javax.swing.ButtonGroup;
|
import javax.swing.ButtonGroup;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
@ -19,20 +21,14 @@ import javax.swing.JLabel;
|
|||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JRadioButton;
|
import javax.swing.JRadioButton;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JSeparator;
|
||||||
import javax.swing.JTextArea;
|
import javax.swing.JTextArea;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.Timer;
|
import javax.swing.Timer;
|
||||||
|
|
||||||
/**
|
public class ClienteSwingProcesamientoJJOO extends JFrame {
|
||||||
*
|
|
||||||
* ClienteIAJuegosOlimpicos
|
|
||||||
*
|
|
||||||
* @author Isidoro
|
|
||||||
* @date 7 feb 2026
|
|
||||||
*/
|
|
||||||
public class ClienteJuegosOlimpicosIA extends JFrame {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -6074564949314600423L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private JTextArea txtPeticion;
|
private JTextArea txtPeticion;
|
||||||
private JButton btnEnviar;
|
private JButton btnEnviar;
|
||||||
@ -40,27 +36,30 @@ public class ClienteJuegosOlimpicosIA extends JFrame {
|
|||||||
private JRadioButton rbOpcion1;
|
private JRadioButton rbOpcion1;
|
||||||
private JRadioButton rbOpcion2;
|
private JRadioButton rbOpcion2;
|
||||||
|
|
||||||
// Panel que se activa / desactiva según la opción
|
|
||||||
private JPanel panelContenido;
|
private JPanel panelContenido;
|
||||||
|
private JLabel lblAyudaOpcion2;
|
||||||
|
|
||||||
public ClienteJuegosOlimpicosIA() {
|
public ClienteSwingProcesamientoJJOO() {
|
||||||
|
|
||||||
// ================= CONFIGURACIÓN VENTANA =================
|
// ================= CONFIGURACIÓN VENTANA =================
|
||||||
setTitle("Cliente IA - Acceso a Datos con IA (Groq)");
|
setTitle("Cliente Swing - Procesamiento de Documentos");
|
||||||
setSize(500, 300);
|
setSize(600, 450);
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
setLocationRelativeTo(null);
|
setLocationRelativeTo(null);
|
||||||
setLayout(new BorderLayout(10, 10));
|
setLayout(new BorderLayout(10, 10));
|
||||||
|
|
||||||
// ================= PANEL NORTE =================
|
// ================= PANEL NORTE =================
|
||||||
JPanel panelNorte = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
JPanel panelNorte = new JPanel();
|
||||||
|
panelNorte.setLayout(new BoxLayout(panelNorte, BoxLayout.Y_AXIS));
|
||||||
|
panelNorte.setBorder(BorderFactory.createEmptyBorder(10, 10, 5, 10));
|
||||||
|
|
||||||
JLabel lblTitulo = new JLabel("Petición a procesar (sobre deportistas):");
|
JLabel lblTitulo = new JLabel(
|
||||||
|
"Procesar información sobre Juegos Olímpicos (Juegos-Mascota, Atletas, Disciplinas)");
|
||||||
lblTitulo.setFont(new Font("SansSerif", Font.BOLD, 13));
|
lblTitulo.setFont(new Font("SansSerif", Font.BOLD, 13));
|
||||||
lblTitulo.setPreferredSize(new Dimension(300, 30));
|
lblTitulo.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||||
|
|
||||||
rbOpcion1 = new JRadioButton("Opción 1");
|
rbOpcion1 = new JRadioButton("Opción 1: Procesar ficheros varios");
|
||||||
rbOpcion2 = new JRadioButton("Opción 2");
|
rbOpcion2 = new JRadioButton("Opción 2: Procesar petición a una IA (Groq)");
|
||||||
|
|
||||||
ButtonGroup grupo = new ButtonGroup();
|
ButtonGroup grupo = new ButtonGroup();
|
||||||
grupo.add(rbOpcion1);
|
grupo.add(rbOpcion1);
|
||||||
@ -68,32 +67,50 @@ public class ClienteJuegosOlimpicosIA extends JFrame {
|
|||||||
|
|
||||||
rbOpcion1.setSelected(true);
|
rbOpcion1.setSelected(true);
|
||||||
|
|
||||||
|
JPanel panelOpciones = new JPanel();
|
||||||
|
panelOpciones.setLayout(new BoxLayout(panelOpciones, BoxLayout.Y_AXIS));
|
||||||
|
panelOpciones.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||||
|
|
||||||
|
panelOpciones.add(rbOpcion1);
|
||||||
|
panelOpciones.add(Box.createVerticalStrut(8));
|
||||||
|
|
||||||
|
JSeparator sepOpciones = new JSeparator();
|
||||||
|
sepOpciones.setMaximumSize(new Dimension(Integer.MAX_VALUE, 1));
|
||||||
|
panelOpciones.add(sepOpciones);
|
||||||
|
|
||||||
|
panelOpciones.add(Box.createVerticalStrut(8));
|
||||||
|
panelOpciones.add(rbOpcion2);
|
||||||
|
|
||||||
panelNorte.add(lblTitulo);
|
panelNorte.add(lblTitulo);
|
||||||
panelNorte.add(rbOpcion1);
|
panelNorte.add(Box.createVerticalStrut(30)); // 👈 separación clara y elegante
|
||||||
panelNorte.add(rbOpcion2);
|
panelNorte.add(panelOpciones);
|
||||||
|
|
||||||
|
|
||||||
add(panelNorte, BorderLayout.NORTH);
|
add(panelNorte, BorderLayout.NORTH);
|
||||||
|
|
||||||
// ================= PANEL CONTENIDO =================
|
// ================= PANEL CONTENIDO (OPCIÓN 2) =================
|
||||||
panelContenido = new JPanel(new BorderLayout());
|
panelContenido = new JPanel(new BorderLayout());
|
||||||
|
panelContenido.setBorder(BorderFactory.createEmptyBorder(0, 25, 0, 0));
|
||||||
|
|
||||||
|
lblAyudaOpcion2 = new JLabel("Introduce aquí la petición que se enviará a la IA:");
|
||||||
|
lblAyudaOpcion2.setFont(new Font("SansSerif", Font.ITALIC, 11));
|
||||||
|
lblAyudaOpcion2.setForeground(Color.DARK_GRAY);
|
||||||
|
lblAyudaOpcion2.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 0));
|
||||||
|
|
||||||
// Caja de texto central
|
|
||||||
txtPeticion = new JTextArea();
|
txtPeticion = new JTextArea();
|
||||||
txtPeticion.setLineWrap(true);
|
txtPeticion.setLineWrap(true);
|
||||||
txtPeticion.setWrapStyleWord(true);
|
txtPeticion.setWrapStyleWord(true);
|
||||||
|
|
||||||
JScrollPane scrollPane = new JScrollPane(txtPeticion);
|
JScrollPane scrollPane = new JScrollPane(txtPeticion);
|
||||||
scrollPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10),
|
scrollPane.setBorder(BorderFactory.createCompoundBorder(
|
||||||
|
BorderFactory.createEmptyBorder(10, 10, 10, 10),
|
||||||
BorderFactory.createLineBorder(Color.GRAY)));
|
BorderFactory.createLineBorder(Color.GRAY)));
|
||||||
|
|
||||||
// ---------- Panel ejemplo ----------
|
|
||||||
JPanel panelEjemplo = new JPanel(new BorderLayout());
|
JPanel panelEjemplo = new JPanel(new BorderLayout());
|
||||||
|
|
||||||
JTextArea txtEjemplo = new JTextArea(
|
JTextArea txtEjemplo = new JTextArea(
|
||||||
"Ejemplo: Obtén información completa, precisa y ordenada de atletas que participaron en juegos olímpicos "
|
"Ejemplo: Obtén información completa, precisa y ordenada de atletas que participaron en juegos olímpicos "
|
||||||
+ "de la siguiente disciplinas: Atletismo, natación y gimnasia. Serán 6 deportistas "
|
+ "de las disciplinas Atletismo, Natación y Gimnasia. Incluye hombres y mujeres de distintos juegos.");
|
||||||
+ "(3 hombres y 3 mujeres) por disciplina. Proporciona información de deportistas "
|
|
||||||
+ "de distintos juegos olímpicos.");
|
|
||||||
|
|
||||||
txtEjemplo.setEditable(false);
|
txtEjemplo.setEditable(false);
|
||||||
txtEjemplo.setLineWrap(true);
|
txtEjemplo.setLineWrap(true);
|
||||||
@ -120,14 +137,24 @@ public class ClienteJuegosOlimpicosIA extends JFrame {
|
|||||||
panelCentral.add(scrollPane, BorderLayout.CENTER);
|
panelCentral.add(scrollPane, BorderLayout.CENTER);
|
||||||
panelCentral.add(panelEjemplo, BorderLayout.SOUTH);
|
panelCentral.add(panelEjemplo, BorderLayout.SOUTH);
|
||||||
|
|
||||||
|
panelContenido.add(lblAyudaOpcion2, BorderLayout.NORTH);
|
||||||
panelContenido.add(panelCentral, BorderLayout.CENTER);
|
panelContenido.add(panelCentral, BorderLayout.CENTER);
|
||||||
|
|
||||||
add(panelContenido, BorderLayout.CENTER);
|
add(panelContenido, BorderLayout.CENTER);
|
||||||
|
|
||||||
// ================= PANEL SUR (BOTÓN COMÚN) =================
|
// ================= PANEL SUR (ACCIÓN GLOBAL) =================
|
||||||
JPanel panelSur = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
JPanel panelSur = new JPanel();
|
||||||
|
panelSur.setLayout(new BoxLayout(panelSur, BoxLayout.Y_AXIS));
|
||||||
|
panelSur.setBorder(BorderFactory.createEmptyBorder(10, 20, 20, 20));
|
||||||
|
|
||||||
btnEnviar = new JButton("Enviar ➤");
|
JSeparator separator = new JSeparator();
|
||||||
|
separator.setMaximumSize(new Dimension(Integer.MAX_VALUE, 1));
|
||||||
|
|
||||||
|
JPanel panelBoton = new JPanel(new FlowLayout(FlowLayout.CENTER));
|
||||||
|
panelBoton.setBorder(BorderFactory.createEmptyBorder(15, 0, 0, 0));
|
||||||
|
|
||||||
|
btnEnviar = new JButton("Procesar ➤");
|
||||||
|
btnEnviar.setPreferredSize(new Dimension(140, 36));
|
||||||
btnEnviar.setBackground(new Color(66, 133, 244));
|
btnEnviar.setBackground(new Color(66, 133, 244));
|
||||||
btnEnviar.setForeground(Color.WHITE);
|
btnEnviar.setForeground(Color.WHITE);
|
||||||
btnEnviar.setFocusPainted(false);
|
btnEnviar.setFocusPainted(false);
|
||||||
@ -140,7 +167,11 @@ public class ClienteJuegosOlimpicosIA extends JFrame {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
panelSur.add(btnEnviar);
|
panelBoton.add(btnEnviar);
|
||||||
|
|
||||||
|
panelSur.add(separator);
|
||||||
|
panelSur.add(panelBoton);
|
||||||
|
|
||||||
add(panelSur, BorderLayout.SOUTH);
|
add(panelSur, BorderLayout.SOUTH);
|
||||||
|
|
||||||
// ================= ESTADO INICIAL =================
|
// ================= ESTADO INICIAL =================
|
||||||
@ -168,15 +199,14 @@ public class ClienteJuegosOlimpicosIA extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void procesarOpcion1() {
|
private void procesarOpcion1() {
|
||||||
System.out.println("Procesando Opción 1 (sin contenido editable)");
|
System.out.println("Procesando Opción 1 (ficheros)");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void procesarOpcion2() {
|
private void procesarOpcion2() {
|
||||||
String textoPrompt = txtPeticion.getText();
|
System.out.println("Procesando Opción 2: " + txtPeticion.getText());
|
||||||
System.out.println("Procesando Opción 2: " + textoPrompt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SwingUtilities.invokeLater(() -> new ClienteJuegosOlimpicosIA().setVisible(true));
|
SwingUtilities.invokeLater(() -> new ClienteSwingProcesamientoJJOO().setVisible(true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user