mirror of
https://gitlab.com/tutorial-java-rafa-munoz/tutorial-java-2024-25/tutorialjava2024-25.git
synced 2025-11-09 09:57:40 +01:00
feat(ch 9): List & Table models from DDBB controllers
This commit is contained in:
@@ -96,14 +96,4 @@ LOCK TABLES `sequence` WRITE;
|
||||
INSERT INTO `sequence` VALUES (20051,'SEQ_GEN');
|
||||
/*!40000 ALTER TABLE `sequence` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2019-05-08 11:03:41
|
||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||
@@ -173,7 +173,8 @@ public class PanelJFileChooserFicheroImagen extends JPanel {
|
||||
Connection conexion = (Connection) DriverManager.getConnection ("jdbc:mysql://localhost/centroeducativo?serverTimezone=UTC","java", "Abcdefgh.1");
|
||||
|
||||
PreparedStatement ps = (PreparedStatement) conexion.
|
||||
prepareStatement("UPDATE centroeducativo.estudiante set imagen=? where id=?");
|
||||
prepareStatement("UPDATE centroeducativo.estudiante "
|
||||
+ "set imagen=? where id=?");
|
||||
|
||||
ps.setBytes(1, imagenEnArrayDeBytes);
|
||||
ps.setInt(2, 1);
|
||||
|
||||
@@ -4,8 +4,8 @@ import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.ListSelectionModel;
|
||||
|
||||
import tutorialJava.modelosBasesDeDatosComunesJPA.poblacionPorProvincias.Provincia;
|
||||
import tutorialJava.modelosBasesDeDatosComunesJPA.poblacionPorProvincias.controladores.ProvinciaControlador;
|
||||
import tutorialJava.capitulo9_AWT_SWING.v05_JListConDefaultListModel.controller.ControladorProvincia;
|
||||
import tutorialJava.capitulo9_AWT_SWING.v05_JListConDefaultListModel.model.Provincia;
|
||||
|
||||
import java.awt.GridBagLayout;
|
||||
|
||||
@@ -24,11 +24,11 @@ public class PanelJList extends JPanel {
|
||||
|
||||
// Elemento JList a utilizar en el ejemplo
|
||||
private JList jlistProvincias;
|
||||
// Modelo del elemento JList, necesario para que podamos c<EFBFBD>modamente agregar y eliminar elementos
|
||||
// Modelo del elemento JList, necesario para que podamos cómodamente agregar y eliminar elementos
|
||||
private DefaultListModel<Provincia> listModelProvincias = null;
|
||||
// Lista de todas las provincias de la BBDD, para incluir en el elemento JList
|
||||
private List<Provincia> provincias = ProvinciaControlador.getControlador().findAllProvincias();
|
||||
// <EFBFBD>ndice de la <EFBFBD>ltima provincia agregada, para saber cu<EFBFBD>l debe ser la siguiente provincia a agregar
|
||||
private List<Provincia> provincias = ControladorProvincia.findAll();
|
||||
// Ìndice de la última provincia agregada, para saber cuál debe ser la siguiente provincia a agregar
|
||||
private int indiceProximaProvinciaParaAgregar = 0;
|
||||
|
||||
/**
|
||||
@@ -50,8 +50,8 @@ public class PanelJList extends JPanel {
|
||||
gbc_lblEjemploDeUso.gridy = 0;
|
||||
add(lblEjemploDeUso, gbc_lblEjemploDeUso);
|
||||
|
||||
// La JList debe ir dentro de un ScrollPane, y se construye con el modelo de JList sobre el que despu<EFBFBD>s
|
||||
// se agregar<EFBFBD>n o eliminar<EFBFBD>n provincias.
|
||||
// La JList debe ir dentro de un ScrollPane, y se construye con el modelo de JList sobre el que después
|
||||
// se agregarán o eliminarán provincias.
|
||||
jlistProvincias = new JList(this.getDefaultListModel());
|
||||
// Tipos de selecci<63>n disponibles en JList
|
||||
//this.jlistProvincias.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
@@ -96,7 +96,7 @@ public class PanelJList extends JPanel {
|
||||
|
||||
|
||||
/**
|
||||
* M<EFBFBD>todo que construye el modelo de JList, a utilizar para agregar y eliminar provincias
|
||||
* Método que construye el modelo de JList, a utilizar para agregar y eliminar provincias
|
||||
*/
|
||||
private DefaultListModel getDefaultListModel () {
|
||||
this.listModelProvincias = new DefaultListModel<Provincia>();
|
||||
@@ -108,16 +108,16 @@ public class PanelJList extends JPanel {
|
||||
*/
|
||||
private void agregarProvincia () {
|
||||
this.listModelProvincias.addElement(this.provincias.get(this.indiceProximaProvinciaParaAgregar));
|
||||
// Aumento el <EFBFBD>ndice de la pr<EFBFBD>xima provincia a agregar
|
||||
// Aumento el índice de la próxima provincia a agregar
|
||||
this.indiceProximaProvinciaParaAgregar++;
|
||||
// Si sobrepasa el l<EFBFBD>mite de las provincias posibles, reiniciamos a valor 0 (cero) el <EFBFBD>ndice de la pr<EFBFBD>xima provincia a agregar
|
||||
// Si sobrepasa el límite de las provincias posibles, reiniciamos a valor 0 (cero) el índice de la próxima provincia a agregar
|
||||
if (this.indiceProximaProvinciaParaAgregar == this.provincias.size()) {
|
||||
this.indiceProximaProvinciaParaAgregar = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Para eliminar todas las provincias seleccionadas, deber<EFBFBD>amos comenzar desde la <EFBFBD>ltima e ir haciendo el barrido hasta la primera.
|
||||
* Para eliminar todas las provincias seleccionadas, deberíamos comenzar desde la última e ir haciendo el barrido hasta la primera.
|
||||
*/
|
||||
private void eliminarProvinciasSeleccionadas () {
|
||||
for (int i = this.jlistProvincias.getSelectedIndices().length - 1; i >= 0; i--) {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package tutorialJava.capitulo9_AWT_SWING.v05_JListConDefaultListModel.controller;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
|
||||
public class ConnectionManager {
|
||||
|
||||
private static Connection conn = null;
|
||||
|
||||
|
||||
public static Connection getConnection() throws Exception {
|
||||
if (conn == null) {
|
||||
Class.forName("com.mysql.cj.jdbc.Driver");
|
||||
|
||||
conn =
|
||||
(Connection) DriverManager.getConnection (
|
||||
"jdbc:mysql://localhost:3306/poblacionprovincia?serverTimezone=UTC",
|
||||
"root", "1234");
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package tutorialJava.capitulo9_AWT_SWING.v05_JListConDefaultListModel.controller;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import tutorialJava.capitulo9_AWT_SWING.v05_JListConDefaultListModel.model.Persona;
|
||||
;
|
||||
|
||||
|
||||
public class ControladorPersona {
|
||||
|
||||
|
||||
public static List<Persona> findAll() {
|
||||
List<Persona> l = new ArrayList<Persona>();
|
||||
|
||||
try {
|
||||
ResultSet rs = ConnectionManager.getConnection().createStatement()
|
||||
.executeQuery("Select * from persona");
|
||||
while (rs.next()) {
|
||||
Persona p = new Persona();
|
||||
p.setId(rs.getInt("id"));
|
||||
p.setNombre(rs.getString("nombre"));
|
||||
p.setApellido1(rs.getString("apellido1"));
|
||||
p.setApellido2(rs.getString("apellido2"));
|
||||
p.setFechaNacimiento(rs.getDate("fechaNacimiento"));
|
||||
p.setEdad(rs.getInt("edad"));
|
||||
p.setActivo(rs.getBoolean("activo"));
|
||||
p.setIdProvincia(rs.getInt("idProvincia"));
|
||||
p.setProvincia(ControladorProvincia.findById(p.getIdProvincia()));
|
||||
l.add(p);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package tutorialJava.capitulo9_AWT_SWING.v05_JListConDefaultListModel.controller;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import tutorialJava.capitulo9_AWT_SWING.v05_JListConDefaultListModel.model.Provincia;
|
||||
|
||||
|
||||
public class ControladorProvincia {
|
||||
|
||||
|
||||
public static List<Provincia> findAll() {
|
||||
List<Provincia> l = new ArrayList<Provincia>();
|
||||
|
||||
try {
|
||||
ResultSet rs = ConnectionManager.getConnection().createStatement()
|
||||
.executeQuery("Select * from provincia");
|
||||
while (rs.next()) {
|
||||
Provincia p = new Provincia();
|
||||
p.setId(rs.getInt("id"));
|
||||
p.setDescripcion(rs.getString("descripcion"));
|
||||
l.add(p);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Provincia findById(int id) {
|
||||
Provincia p = null;
|
||||
|
||||
try {
|
||||
ResultSet rs = ConnectionManager.getConnection().createStatement()
|
||||
.executeQuery("Select * from provincia where id = " + id);
|
||||
if (rs.next()) {
|
||||
p = new Provincia();
|
||||
p.setId(rs.getInt("id"));
|
||||
p.setDescripcion(rs.getString("descripcion"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
package tutorialJava.capitulo9_AWT_SWING.v05_JListConDefaultListModel.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class Persona {
|
||||
private int id;
|
||||
private String nombre;
|
||||
private String apellido1;
|
||||
private String apellido2;
|
||||
private Date fechaNacimiento;
|
||||
private int edad;
|
||||
private boolean activo;
|
||||
private int idProvincia;
|
||||
private Provincia provincia;
|
||||
|
||||
public Persona() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Persona(int id, String nombre, String apellido1, String apellido2, Date fechaNacimiento, int edad,
|
||||
boolean activo, int idProvincia) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.nombre = nombre;
|
||||
this.apellido1 = apellido1;
|
||||
this.apellido2 = apellido2;
|
||||
this.fechaNacimiento = fechaNacimiento;
|
||||
this.edad = edad;
|
||||
this.activo = activo;
|
||||
this.idProvincia = idProvincia;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getNombre() {
|
||||
return nombre;
|
||||
}
|
||||
|
||||
public void setNombre(String nombre) {
|
||||
this.nombre = nombre;
|
||||
}
|
||||
|
||||
public String getApellido1() {
|
||||
return apellido1;
|
||||
}
|
||||
|
||||
public void setApellido1(String apellido1) {
|
||||
this.apellido1 = apellido1;
|
||||
}
|
||||
|
||||
public String getApellido2() {
|
||||
return apellido2;
|
||||
}
|
||||
|
||||
public void setApellido2(String apellido2) {
|
||||
this.apellido2 = apellido2;
|
||||
}
|
||||
|
||||
public Date getFechaNacimiento() {
|
||||
return fechaNacimiento;
|
||||
}
|
||||
|
||||
public void setFechaNacimiento(Date fechaNacimiento) {
|
||||
this.fechaNacimiento = fechaNacimiento;
|
||||
}
|
||||
|
||||
public int getEdad() {
|
||||
return edad;
|
||||
}
|
||||
|
||||
public void setEdad(int edad) {
|
||||
this.edad = edad;
|
||||
}
|
||||
|
||||
public boolean isActivo() {
|
||||
return activo;
|
||||
}
|
||||
|
||||
public void setActivo(boolean activo) {
|
||||
this.activo = activo;
|
||||
}
|
||||
|
||||
public int getIdProvincia() {
|
||||
return idProvincia;
|
||||
}
|
||||
|
||||
public void setIdProvincia(int idProvincia) {
|
||||
this.idProvincia = idProvincia;
|
||||
}
|
||||
|
||||
public Provincia getProvincia() {
|
||||
return provincia;
|
||||
}
|
||||
|
||||
public void setProvincia(Provincia provincia) {
|
||||
this.provincia = provincia;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Persona [id=" + id + ", nombre=" + nombre + ", apellido1=" + apellido1 + ", apellido2=" + apellido2
|
||||
+ ", fechaNacimiento=" + fechaNacimiento + ", edad=" + edad + ", activo=" + activo + ", idProvincia="
|
||||
+ idProvincia + ", provincia=" + provincia + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package tutorialJava.capitulo9_AWT_SWING.v05_JListConDefaultListModel.model;
|
||||
|
||||
public class Provincia {
|
||||
private int id;
|
||||
private String descripcion;
|
||||
|
||||
public Provincia() {
|
||||
}
|
||||
|
||||
public Provincia(int id, String descripcion) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.descripcion = descripcion;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getDescripcion() {
|
||||
return descripcion;
|
||||
}
|
||||
|
||||
public void setDescripcion(String descripcion) {
|
||||
this.descripcion = descripcion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return descripcion;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -2,8 +2,9 @@ package tutorialJava.capitulo9_AWT_SWING.v06_EjemplosJTable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tutorialJava.modelosBasesDeDatosComunesJPA.poblacionPorProvincias.Persona;
|
||||
import tutorialJava.modelosBasesDeDatosComunesJPA.poblacionPorProvincias.controladores.PersonaControlador;
|
||||
import tutorialJava.capitulo9_AWT_SWING.v05_JListConDefaultListModel.controller.ControladorPersona;
|
||||
import tutorialJava.capitulo9_AWT_SWING.v05_JListConDefaultListModel.model.Persona;
|
||||
|
||||
|
||||
public class DatosDeTabla {
|
||||
|
||||
@@ -12,7 +13,7 @@ public class DatosDeTabla {
|
||||
* @return
|
||||
*/
|
||||
public static String[] getTitulosColumnas() {
|
||||
return new String[] {"Id", "Nombre", "1<EFBFBD> apellido", "2<EFBFBD> apellido", "Fecha Nac.", "Edad", "Activo", "Provincia"};
|
||||
return new String[] {"Id", "Nombre", "1º apellido", "2º apellido", "Fecha Nac.", "Edad", "Activo", "Provincia"};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -21,7 +22,7 @@ public class DatosDeTabla {
|
||||
*/
|
||||
public static Object[][] getDatosDeTabla() {
|
||||
// Obtengo todas las personas
|
||||
List<Persona> personas = PersonaControlador.getControlador().findAllPersonas();
|
||||
List<Persona> personas = ControladorPersona.findAll();
|
||||
// Preparo una estructura para pasar al constructor de la JTable
|
||||
Object[][] datos = new Object[personas.size()][8];
|
||||
// Cargo los datos de la lista de personas en la matriz de los datos
|
||||
@@ -29,11 +30,11 @@ public class DatosDeTabla {
|
||||
Persona persona = personas.get(i);
|
||||
datos[i][0] = persona.getId();
|
||||
datos[i][1] = persona.getNombre();
|
||||
datos[i][2] = persona.getPrimerApellido();
|
||||
datos[i][3] = persona.getSegundoApellido();
|
||||
datos[i][2] = persona.getApellido1();
|
||||
datos[i][3] = persona.getApellido2();
|
||||
datos[i][4] = persona.getFechaNacimiento();
|
||||
datos[i][5] = persona.getEdad();
|
||||
datos[i][6] = persona.getActivo();
|
||||
datos[i][6] = persona.isActivo();
|
||||
datos[i][7] = persona.getProvincia();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,9 @@ import javax.swing.DefaultCellEditor;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JTable;
|
||||
|
||||
import tutorialJava.modelosBasesDeDatosComunesJPA.poblacionPorProvincias.Provincia;
|
||||
import tutorialJava.modelosBasesDeDatosComunesJPA.poblacionPorProvincias.controladores.ProvinciaControlador;
|
||||
import tutorialJava.capitulo9_AWT_SWING.v05_JListConDefaultListModel.controller.ControladorProvincia;
|
||||
import tutorialJava.capitulo9_AWT_SWING.v05_JListConDefaultListModel.model.Provincia;
|
||||
|
||||
|
||||
public class MiProvinciaTableCellEditor extends DefaultCellEditor {
|
||||
|
||||
@@ -37,7 +38,7 @@ public class MiProvinciaTableCellEditor extends DefaultCellEditor {
|
||||
jcbProvincias.removeAllItems();
|
||||
|
||||
// Inicializo los elementos del combobox a todas las provincias disponibles y selecciono la correcta
|
||||
List<Provincia> provincias = ProvinciaControlador.getControlador().findAllProvincias();
|
||||
List<Provincia> provincias = ControladorProvincia.findAll();
|
||||
for (Provincia provincia : provincias) {
|
||||
jcbProvincias.addItem(provincia);
|
||||
if (value != null && value instanceof Provincia) {
|
||||
|
||||
@@ -11,7 +11,8 @@ import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JTextArea;
|
||||
|
||||
import tutorialJava.modelosBasesDeDatosComunesJPA.poblacionPorProvincias.Provincia;
|
||||
import tutorialJava.capitulo9_AWT_SWING.v05_JListConDefaultListModel.model.Provincia;
|
||||
|
||||
|
||||
public class TablaEnScrollPane extends JPanel {
|
||||
|
||||
|
||||
246
src/tutorialJava/examenes/examen20250404/GestionBiblioteca.java
Normal file
246
src/tutorialJava/examenes/examen20250404/GestionBiblioteca.java
Normal file
@@ -0,0 +1,246 @@
|
||||
package tutorialJava.examenes.examen20250404;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.GridBagLayout;
|
||||
import javax.swing.JLabel;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.Font;
|
||||
import java.awt.Insets;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
|
||||
public class GestionBiblioteca extends JFrame {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private JPanel contentPane;
|
||||
private JTextField jtfFiltroTituloLibro;
|
||||
private JTextField jtfFiltroAutorLibro;
|
||||
private JTextField textField;
|
||||
private JTextField textField_1;
|
||||
private JTextField textField_2;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
GestionBiblioteca frame = new GestionBiblioteca();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public GestionBiblioteca() {
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 450, 300);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
|
||||
setContentPane(contentPane);
|
||||
GridBagLayout gbl_contentPane = new GridBagLayout();
|
||||
gbl_contentPane.columnWidths = new int[]{0, 0, 0};
|
||||
gbl_contentPane.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
gbl_contentPane.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
|
||||
gbl_contentPane.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
||||
contentPane.setLayout(gbl_contentPane);
|
||||
|
||||
JLabel lblNewLabel = new JLabel("Gestión de préstamos de biblioteca");
|
||||
lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 14));
|
||||
GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
|
||||
gbc_lblNewLabel.gridwidth = 2;
|
||||
gbc_lblNewLabel.insets = new Insets(10, 0, 10, 0);
|
||||
gbc_lblNewLabel.gridx = 0;
|
||||
gbc_lblNewLabel.gridy = 0;
|
||||
contentPane.add(lblNewLabel, gbc_lblNewLabel);
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("Categoría literaria:");
|
||||
GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
|
||||
gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5);
|
||||
gbc_lblNewLabel_1.anchor = GridBagConstraints.EAST;
|
||||
gbc_lblNewLabel_1.gridx = 0;
|
||||
gbc_lblNewLabel_1.gridy = 1;
|
||||
contentPane.add(lblNewLabel_1, gbc_lblNewLabel_1);
|
||||
|
||||
JComboBox jcbCategoria = new JComboBox();
|
||||
jcbCategoria.setModel(new DefaultComboBoxModel(new String[] {"Novela"}));
|
||||
GridBagConstraints gbc_jcbCategoria = new GridBagConstraints();
|
||||
gbc_jcbCategoria.insets = new Insets(0, 0, 5, 0);
|
||||
gbc_jcbCategoria.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc_jcbCategoria.gridx = 1;
|
||||
gbc_jcbCategoria.gridy = 1;
|
||||
contentPane.add(jcbCategoria, gbc_jcbCategoria);
|
||||
|
||||
JLabel lblNewLabel_2 = new JLabel("Filtro de título de libro:");
|
||||
GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints();
|
||||
gbc_lblNewLabel_2.anchor = GridBagConstraints.EAST;
|
||||
gbc_lblNewLabel_2.insets = new Insets(0, 0, 5, 5);
|
||||
gbc_lblNewLabel_2.gridx = 0;
|
||||
gbc_lblNewLabel_2.gridy = 2;
|
||||
contentPane.add(lblNewLabel_2, gbc_lblNewLabel_2);
|
||||
|
||||
jtfFiltroTituloLibro = new JTextField();
|
||||
jtfFiltroTituloLibro.setText("Cien");
|
||||
GridBagConstraints gbc_jtfFiltroTituloLibro = new GridBagConstraints();
|
||||
gbc_jtfFiltroTituloLibro.insets = new Insets(0, 0, 5, 0);
|
||||
gbc_jtfFiltroTituloLibro.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc_jtfFiltroTituloLibro.gridx = 1;
|
||||
gbc_jtfFiltroTituloLibro.gridy = 2;
|
||||
contentPane.add(jtfFiltroTituloLibro, gbc_jtfFiltroTituloLibro);
|
||||
jtfFiltroTituloLibro.setColumns(10);
|
||||
|
||||
JLabel lblNewLabel_3 = new JLabel("Filtro de autor de libro:");
|
||||
GridBagConstraints gbc_lblNewLabel_3 = new GridBagConstraints();
|
||||
gbc_lblNewLabel_3.anchor = GridBagConstraints.EAST;
|
||||
gbc_lblNewLabel_3.insets = new Insets(0, 0, 5, 5);
|
||||
gbc_lblNewLabel_3.gridx = 0;
|
||||
gbc_lblNewLabel_3.gridy = 3;
|
||||
contentPane.add(lblNewLabel_3, gbc_lblNewLabel_3);
|
||||
|
||||
jtfFiltroAutorLibro = new JTextField();
|
||||
jtfFiltroAutorLibro.setText("García");
|
||||
GridBagConstraints gbc_jtfFiltroAutorLibro = new GridBagConstraints();
|
||||
gbc_jtfFiltroAutorLibro.insets = new Insets(0, 0, 5, 0);
|
||||
gbc_jtfFiltroAutorLibro.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc_jtfFiltroAutorLibro.gridx = 1;
|
||||
gbc_jtfFiltroAutorLibro.gridy = 3;
|
||||
contentPane.add(jtfFiltroAutorLibro, gbc_jtfFiltroAutorLibro);
|
||||
jtfFiltroAutorLibro.setColumns(10);
|
||||
|
||||
JButton btnFiltrarLibros = new JButton("Filtrar libros");
|
||||
GridBagConstraints gbc_btnFiltrarLibros = new GridBagConstraints();
|
||||
gbc_btnFiltrarLibros.insets = new Insets(0, 0, 5, 0);
|
||||
gbc_btnFiltrarLibros.gridx = 1;
|
||||
gbc_btnFiltrarLibros.gridy = 4;
|
||||
contentPane.add(btnFiltrarLibros, gbc_btnFiltrarLibros);
|
||||
|
||||
JLabel lblNewLabel_4 = new JLabel("Libros filtrados:");
|
||||
GridBagConstraints gbc_lblNewLabel_4 = new GridBagConstraints();
|
||||
gbc_lblNewLabel_4.anchor = GridBagConstraints.EAST;
|
||||
gbc_lblNewLabel_4.insets = new Insets(0, 0, 5, 5);
|
||||
gbc_lblNewLabel_4.gridx = 0;
|
||||
gbc_lblNewLabel_4.gridy = 5;
|
||||
contentPane.add(lblNewLabel_4, gbc_lblNewLabel_4);
|
||||
|
||||
JComboBox jcbLibrosFiltrados = new JComboBox();
|
||||
jcbLibrosFiltrados.setModel(new DefaultComboBoxModel(new String[] {"Cien años de soledad - Gabriel García Márquez"}));
|
||||
GridBagConstraints gbc_jcbLibrosFiltrados = new GridBagConstraints();
|
||||
gbc_jcbLibrosFiltrados.insets = new Insets(0, 0, 5, 0);
|
||||
gbc_jcbLibrosFiltrados.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc_jcbLibrosFiltrados.gridx = 1;
|
||||
gbc_jcbLibrosFiltrados.gridy = 5;
|
||||
contentPane.add(jcbLibrosFiltrados, gbc_jcbLibrosFiltrados);
|
||||
|
||||
JLabel lblNewLabel_5 = new JLabel("Datos del préstamo del libro");
|
||||
lblNewLabel_5.setFont(new Font("Tahoma", Font.BOLD, 14));
|
||||
GridBagConstraints gbc_lblNewLabel_5 = new GridBagConstraints();
|
||||
gbc_lblNewLabel_5.gridwidth = 2;
|
||||
gbc_lblNewLabel_5.insets = new Insets(10, 0, 10, 0);
|
||||
gbc_lblNewLabel_5.gridx = 0;
|
||||
gbc_lblNewLabel_5.gridy = 6;
|
||||
contentPane.add(lblNewLabel_5, gbc_lblNewLabel_5);
|
||||
|
||||
JLabel lblNewLabel_6 = new JLabel("Id préstamo:");
|
||||
GridBagConstraints gbc_lblNewLabel_6 = new GridBagConstraints();
|
||||
gbc_lblNewLabel_6.anchor = GridBagConstraints.EAST;
|
||||
gbc_lblNewLabel_6.insets = new Insets(0, 0, 5, 5);
|
||||
gbc_lblNewLabel_6.gridx = 0;
|
||||
gbc_lblNewLabel_6.gridy = 7;
|
||||
contentPane.add(lblNewLabel_6, gbc_lblNewLabel_6);
|
||||
|
||||
textField = new JTextField();
|
||||
textField.setEnabled(false);
|
||||
textField.setText("1");
|
||||
GridBagConstraints gbc_textField = new GridBagConstraints();
|
||||
gbc_textField.insets = new Insets(0, 0, 5, 0);
|
||||
gbc_textField.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc_textField.gridx = 1;
|
||||
gbc_textField.gridy = 7;
|
||||
contentPane.add(textField, gbc_textField);
|
||||
textField.setColumns(10);
|
||||
|
||||
JLabel lblNewLabel_7 = new JLabel("Usuario:");
|
||||
GridBagConstraints gbc_lblNewLabel_7 = new GridBagConstraints();
|
||||
gbc_lblNewLabel_7.anchor = GridBagConstraints.EAST;
|
||||
gbc_lblNewLabel_7.insets = new Insets(0, 0, 5, 5);
|
||||
gbc_lblNewLabel_7.gridx = 0;
|
||||
gbc_lblNewLabel_7.gridy = 8;
|
||||
contentPane.add(lblNewLabel_7, gbc_lblNewLabel_7);
|
||||
|
||||
JComboBox jcbUsuario = new JComboBox();
|
||||
jcbUsuario.setModel(new DefaultComboBoxModel(new String[] {"Ana López - 12345678A"}));
|
||||
GridBagConstraints gbc_jcbUsuario = new GridBagConstraints();
|
||||
gbc_jcbUsuario.insets = new Insets(0, 0, 5, 0);
|
||||
gbc_jcbUsuario.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc_jcbUsuario.gridx = 1;
|
||||
gbc_jcbUsuario.gridy = 8;
|
||||
contentPane.add(jcbUsuario, gbc_jcbUsuario);
|
||||
|
||||
JLabel lblNewLabel_8 = new JLabel("Fecha del préstamo:");
|
||||
GridBagConstraints gbc_lblNewLabel_8 = new GridBagConstraints();
|
||||
gbc_lblNewLabel_8.anchor = GridBagConstraints.EAST;
|
||||
gbc_lblNewLabel_8.insets = new Insets(0, 0, 5, 5);
|
||||
gbc_lblNewLabel_8.gridx = 0;
|
||||
gbc_lblNewLabel_8.gridy = 9;
|
||||
contentPane.add(lblNewLabel_8, gbc_lblNewLabel_8);
|
||||
|
||||
textField_1 = new JTextField();
|
||||
textField_1.setText("2025-03-01");
|
||||
GridBagConstraints gbc_textField_1 = new GridBagConstraints();
|
||||
gbc_textField_1.insets = new Insets(0, 0, 5, 0);
|
||||
gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc_textField_1.gridx = 1;
|
||||
gbc_textField_1.gridy = 9;
|
||||
contentPane.add(textField_1, gbc_textField_1);
|
||||
textField_1.setColumns(10);
|
||||
|
||||
JLabel lblNewLabel_9 = new JLabel("Fecha de devolución:");
|
||||
GridBagConstraints gbc_lblNewLabel_9 = new GridBagConstraints();
|
||||
gbc_lblNewLabel_9.anchor = GridBagConstraints.EAST;
|
||||
gbc_lblNewLabel_9.insets = new Insets(0, 0, 5, 5);
|
||||
gbc_lblNewLabel_9.gridx = 0;
|
||||
gbc_lblNewLabel_9.gridy = 10;
|
||||
contentPane.add(lblNewLabel_9, gbc_lblNewLabel_9);
|
||||
|
||||
textField_2 = new JTextField();
|
||||
textField_2.setText("2025-03-15");
|
||||
GridBagConstraints gbc_textField_2 = new GridBagConstraints();
|
||||
gbc_textField_2.insets = new Insets(0, 0, 5, 0);
|
||||
gbc_textField_2.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc_textField_2.gridx = 1;
|
||||
gbc_textField_2.gridy = 10;
|
||||
contentPane.add(textField_2, gbc_textField_2);
|
||||
textField_2.setColumns(10);
|
||||
|
||||
JCheckBox chckbxNewCheckBox = new JCheckBox("Préstamo activo");
|
||||
GridBagConstraints gbc_chckbxNewCheckBox = new GridBagConstraints();
|
||||
gbc_chckbxNewCheckBox.insets = new Insets(0, 0, 5, 0);
|
||||
gbc_chckbxNewCheckBox.anchor = GridBagConstraints.WEST;
|
||||
gbc_chckbxNewCheckBox.gridx = 1;
|
||||
gbc_chckbxNewCheckBox.gridy = 11;
|
||||
contentPane.add(chckbxNewCheckBox, gbc_chckbxNewCheckBox);
|
||||
|
||||
JButton btnGuardar = new JButton("Guardar cambios del préstamo");
|
||||
GridBagConstraints gbc_btnGuardar = new GridBagConstraints();
|
||||
gbc_btnGuardar.gridwidth = 2;
|
||||
gbc_btnGuardar.insets = new Insets(0, 0, 0, 5);
|
||||
gbc_btnGuardar.gridx = 0;
|
||||
gbc_btnGuardar.gridy = 12;
|
||||
contentPane.add(btnGuardar, gbc_btnGuardar);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user