racePanel GUI 1.0

This commit is contained in:
Josh Ashton
2022-11-09 21:15:41 -07:00
parent bd64de79e5
commit 39d6470e66
4 changed files with 67 additions and 25 deletions
+49 -7
View File
@@ -1,27 +1,69 @@
package GUI.Panels;
import javax.swing.JPanel;
import javax.swing.*;
import java.awt.BorderLayout;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ChooseRacePanel extends JPanel {
private String raceChoice;
/**
* Create the panel.
*/
public ChooseRacePanel() {
createPanel();
super();
createMasterPanel();
}
private void createPanel() {
private void createMasterPanel() {
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]));
}
masterPanel.add(racesContainer);
add(masterPanel);
}
private JButton createButton(String raceName) {
JButton button = new JButton(raceName);
button.addActionListener(
new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
raceChoice = raceName;
}
}
);
return button;
}