racePanel GUI 1.0
This commit is contained in:
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user