Primer commit
This commit is contained in:
commit
daf6a9a646
11
.classpath
Normal file
11
.classpath
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk-25">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/aadd_act2_3"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/target/
|
||||
*.class
|
||||
17
.project
Normal file
17
.project
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>PruebaActividad2_3</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
2
.settings/org.eclipse.core.resources.prefs
Normal file
2
.settings/org.eclipse.core.resources.prefs
Normal file
@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
14
.settings/org.eclipse.jdt.core.prefs
Normal file
14
.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,14 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=24
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=24
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=24
|
||||
139
src/es/lapaloma/swing/VentanaPruebaActividad2_3.java
Normal file
139
src/es/lapaloma/swing/VentanaPruebaActividad2_3.java
Normal file
@ -0,0 +1,139 @@
|
||||
package es.lapaloma.swing;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import es.palomafp.aadd.inm.GestorMapaMundi;
|
||||
import es.palomafp.aadd.inm.vo.Continente;
|
||||
import es.palomafp.aadd.inm.vo.Pais;
|
||||
|
||||
/**
|
||||
*
|
||||
* VentanaPruebaActividad2_3: Clase que realiza ....
|
||||
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
|
||||
* @date 6 nov 2025
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public class VentanaPruebaActividad2_3 extends JFrame{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6446806124468802268L;
|
||||
private JTextArea salidaArea;
|
||||
|
||||
public VentanaPruebaActividad2_3() {
|
||||
setTitle("Pruebas AADD actividad 2.3 - Mapa Mundi");
|
||||
setSize(500, 400);
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setLocationRelativeTo(null);
|
||||
|
||||
// Layout principal
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
// Panel de botones
|
||||
JPanel panelBotones = new JPanel();
|
||||
panelBotones.setLayout(new GridLayout(4, 1, 10, 10));
|
||||
|
||||
JButton btnConsultar = new JButton("1. Consultar países de América que empiezan por 'Sa'");
|
||||
JButton btnAnadir = new JButton("2. Añadir nuevo continente");
|
||||
JButton btnActualizar = new JButton("3. Actualizar país con código 107");
|
||||
JButton btnEliminar = new JButton("4. Eliminar continente con código 02");
|
||||
|
||||
panelBotones.add(btnConsultar);
|
||||
panelBotones.add(btnAnadir);
|
||||
panelBotones.add(btnActualizar);
|
||||
panelBotones.add(btnEliminar);
|
||||
|
||||
add(panelBotones, BorderLayout.NORTH);
|
||||
|
||||
// Área de salida
|
||||
salidaArea = new JTextArea();
|
||||
salidaArea.setEditable(false);
|
||||
salidaArea.setFont(new Font("Monospaced", Font.PLAIN, 12));
|
||||
add(new JScrollPane(salidaArea), BorderLayout.CENTER);
|
||||
|
||||
// Acción de cada botón
|
||||
btnConsultar.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
salidaArea.append("Ejecutando consulta...\n");
|
||||
try {
|
||||
GestorMapaMundi gestor = new GestorMapaMundi();
|
||||
List<Pais> listaPaises = gestor.consultarPaisesAmericanosEmpiezanSa();
|
||||
for(Pais pais : listaPaises) {
|
||||
String infoPais = "%s (%d) pertenece al continente %s (%s)";
|
||||
infoPais = String.format(infoPais, pais.getNombre(), pais.getIdentificador(),
|
||||
pais.getContinente().getNombre(), pais.getContinente().getCodigo());
|
||||
|
||||
salidaArea.append(infoPais+ "\n");
|
||||
}
|
||||
salidaArea.append("Consulta completada.\n\n");
|
||||
} catch (Exception ex) {
|
||||
salidaArea.append("Error: " + ex.getMessage() + "\n\n");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
btnAnadir.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
salidaArea.append("Añadiendo nuevo continente...\n");
|
||||
try {
|
||||
GestorMapaMundi gestor = new GestorMapaMundi();
|
||||
Continente continente = new Continente();
|
||||
continente.setCodigo("06");
|
||||
continente.setNombre("Antártida");
|
||||
gestor.anyadirContinente(continente);
|
||||
|
||||
salidaArea.append("Continente "+ continente +"añadido.\n\n");
|
||||
} catch (Exception ex) {
|
||||
salidaArea.append("Error: " + ex.getMessage() + "\n\n");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
btnActualizar.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
salidaArea.append("Actualizando país con código 107...\n");
|
||||
try {
|
||||
GestorMapaMundi gestor = new GestorMapaMundi();
|
||||
Pais pais = gestor.actualizarPaisCodigo107();
|
||||
salidaArea.append("País con código 107 actualizado: "+ pais + ".\n\n");
|
||||
} catch (Exception ex) {
|
||||
salidaArea.append("Error: " + ex.getMessage() + "\n\n");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
btnEliminar.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
salidaArea.append("Eliminando continente con código 02...\n");
|
||||
try {
|
||||
GestorMapaMundi gestor = new GestorMapaMundi();
|
||||
gestor.eliminarContinente("02");
|
||||
salidaArea.append("Continente con código 02 eliminado.\n\n");
|
||||
} catch (Exception ex) {
|
||||
salidaArea.append("Error: " + ex.getMessage() + "\n\n");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
new VentanaPruebaActividad2_3().setVisible(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user