Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Mackaber committed Jul 3, 2023
0 parents commit 1292099
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Reto-Semana-4.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Binary file added out/production/Reto-Semana-4/Main.class
Binary file not shown.
88 changes: 88 additions & 0 deletions src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import javax.swing.*;
import java.awt.*;

public class Main {
private static final int TOTAL_PAGES = 3;
private static int currentPage = 1;
private static JPanel pagePanel;

private static JPanel page1() {
JPanel panel = new JPanel();
JLabel label = new JLabel("Página 1");

// TODO: Agregar JLabel y JTextField para la pregunta y la respuesta

panel.add(label);
return panel;
}

// TODO: Agregar las funciones page2() page3() y page4()
// (para las páginas respectivas)

private static void goToPage(int pageNumber) {
JPanel page = page1();

switch (pageNumber) {
case 1:
page = page1();
break;

// TODO: Agregar case 2, 3 y 4 (para las páginas respectivas)

default:
page = page1();
break;
}

pagePanel.removeAll();
pagePanel.add(page);
pagePanel.revalidate();
pagePanel.repaint();
}

private static void createAndShowGUI() {
JFrame frame = new JFrame("Reto Semana 4");
frame.setLayout(new BorderLayout());

// Crear el panel de páginas
pagePanel = new JPanel();
pagePanel.setLayout(new FlowLayout());
frame.add(pagePanel, BorderLayout.CENTER);

// Crear el panel de botones
JPanel buttonPanel = new JPanel();

// Botón "Anterior"
JButton previousButton = new JButton("Anterior");
previousButton.addActionListener(e -> {
if (currentPage > 1) {
currentPage--;
goToPage(currentPage);
}
});

// Botón "Siguiente"
JButton nextButton = new JButton("Siguiente");
nextButton.addActionListener(e -> {
if (currentPage < TOTAL_PAGES) {
currentPage++;
goToPage(currentPage);
}
});
buttonPanel.add(previousButton);
buttonPanel.add(nextButton);
frame.add(buttonPanel, BorderLayout.SOUTH);

// Configurar la ventana
frame.setSize(300, 200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);

// Mostrar la página inicial
goToPage(1);
}

public static void main(String[] args) {
createAndShowGUI();
}
}

0 comments on commit 1292099

Please sign in to comment.