added forward/previous page logic to GUI

This commit is contained in:
Joshua-Ashton01
2022-11-15 10:43:34 -07:00
parent 30de7d2fa9
commit 86c9f9e555
15 changed files with 367 additions and 757 deletions
+54 -70
View File
@@ -1,83 +1,67 @@
package GUI.Panels;
import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.BevelBorder;
import javax.swing.JTextPane;
public class ChooseRacePanel extends JPanel {
private String raceChoice;
private boolean ableToContinue;
public ChooseRacePanel() {
super();
createMasterPanel();
}
private void createMasterPanel() {
/**
* Create the panel.
*/
public ChooseRacePanel(JButton backButton, JButton continueButton) {
setBackground(new Color(222, 184, 135));
setBorder(new BevelBorder(BevelBorder.RAISED, new Color(160, 82, 45), new Color(165, 42, 42), new Color(0, 0, 0), null));
setLayout(new BorderLayout(0, 0));
JPanel masterPanel = new JPanel();
JLabel title = new JLabel("Step 1: Choose Race");
title.setHorizontalAlignment(SwingConstants.CENTER);
masterPanel.add(title, BorderLayout.NORTH);
JPanel racesContainer = new JPanel();
String[] availableRaces = {"Dragonborn", "Dwarf", "Elf", "Gnome", "Half-Elf", "Halfling", "Half-Orc", "Human", "Tiefling"};
for (int i = 0; i < availableRaces.length; i++) {
racesContainer.add(createButton(availableRaces[i]));
JLabel lblNewLabel = new JLabel("Step 1: Choose Race");
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel.setFont(new Font("Bodoni 72 Oldstyle", Font.PLAIN, 33));
add(lblNewLabel, BorderLayout.NORTH);
JPanel racePanel = new JPanel();
racePanel.setOpaque(false);
add(racePanel, BorderLayout.CENTER);
racePanel.setLayout(null);
JTextPane textPane = new JTextPane();
textPane.setBounds(47, 67, 223, 301);
racePanel.add(textPane);
JPanel raceBtnPanel = new JPanel();
raceBtnPanel.setBackground(new Color(165, 42, 42));
raceBtnPanel.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
raceBtnPanel.setBounds(311, 6, 409, 394);
racePanel.add(raceBtnPanel);
JButton dragonbornBtn = new JButton("Dragonborn");
dragonbornBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
masterPanel.add(racesContainer);
add(masterPanel);
});
raceBtnPanel.add(dragonbornBtn);
JPanel backContPanel = new JPanel();
backContPanel.setBackground(new Color(205, 133, 63));
add(backContPanel, BorderLayout.SOUTH);
JButton backBtn = new JButton("<--- Back ");
// backContPanel.add(backBtn);
backContPanel.add(backButton);
JButton continueBtn = new JButton("Continue --->");
// backContPanel.add(continueBtn);
backContPanel.add(continueButton);
}
private JButton createButton(String userChoice) {
JButton button = new JButton(userChoice);
button.addActionListener(
new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println(userChoice);
raceChoice = userChoice;
ableToContinue = true;
}
}
);
return button;
}
public String getRaceChoice() {
return raceChoice;
}
public boolean isAbleToContinue() {
return ableToContinue;
}
}