refactoring GUI panels and adding race images.
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
package GUI;
|
||||
|
||||
import Character.AbilityScores.Stats;
|
||||
import Character.Classes.*;
|
||||
import Character.Races.*;
|
||||
import GUI.Panels.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.*;
|
||||
|
||||
/* private void getNextPanel() {
|
||||
|
||||
@@ -62,7 +64,7 @@ public class GUImanager extends JFrame {
|
||||
|
||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
setLayout(new BorderLayout());
|
||||
setPreferredSize(new Dimension(735,550));
|
||||
setPreferredSize(new Dimension(730,550));
|
||||
setSize(getPreferredSize());
|
||||
|
||||
try {
|
||||
@@ -98,7 +100,6 @@ public class GUImanager extends JFrame {
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
System.out.println("Back button registered.");
|
||||
|
||||
lastPanel--;
|
||||
currentPanel--;
|
||||
@@ -122,7 +123,7 @@ public class GUImanager extends JFrame {
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
System.out.println("Continue button registered.");
|
||||
|
||||
lastPanel++;
|
||||
currentPanel++;
|
||||
nextPanel++;
|
||||
@@ -135,6 +136,60 @@ public class GUImanager extends JFrame {
|
||||
|
||||
return button;
|
||||
|
||||
}
|
||||
|
||||
private JButton createRandomCharacterButton() {
|
||||
|
||||
JButton button = new JButton("Create Random Character");
|
||||
button.addActionListener(
|
||||
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
createRandomCharacter();
|
||||
|
||||
lastPanel = currentPanel;
|
||||
currentPanel = 6;
|
||||
nextPanel = currentPanel + 1;
|
||||
clearAndReset();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
return button;
|
||||
|
||||
}
|
||||
|
||||
private JButton createSaveButton() {
|
||||
|
||||
JButton button = new JButton("Save");
|
||||
button.addActionListener(
|
||||
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
lastPanel = currentPanel;
|
||||
currentPanel = 6;
|
||||
nextPanel = currentPanel + 1;
|
||||
clearAndReset();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
return button;
|
||||
|
||||
}
|
||||
|
||||
private void createRandomCharacter() {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void clearAndReset() {
|
||||
|
||||
@@ -1,67 +1,110 @@
|
||||
package GUI.Panels;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
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;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
|
||||
public class ChooseRacePanel extends JPanel {
|
||||
|
||||
private String raceChoice;
|
||||
private JButton backButton;
|
||||
private JButton continueButton;
|
||||
|
||||
/**
|
||||
* Create the panel.
|
||||
*/
|
||||
public ChooseRacePanel(JButton backButton, JButton continueButton) {
|
||||
super();
|
||||
this.backButton = backButton;
|
||||
this.continueButton = continueButton;
|
||||
|
||||
panelSetup();
|
||||
|
||||
add(createMasterPanel());
|
||||
|
||||
}
|
||||
|
||||
private JPanel createMasterPanel() {
|
||||
|
||||
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);
|
||||
racePanel.setLayout(null);
|
||||
|
||||
JTextPane textPane = new JTextPane();
|
||||
textPane.setBounds(47, 67, 223, 301);
|
||||
racePanel.add(textPane);
|
||||
|
||||
racePanel.add(createRaceButtonPanel());
|
||||
|
||||
add(createNavPanel(), BorderLayout.SOUTH);
|
||||
|
||||
return racePanel;
|
||||
|
||||
}
|
||||
|
||||
private JPanel createRaceButtonPanel() {
|
||||
|
||||
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);
|
||||
|
||||
String[] raceOptions = {"Dragonborn", "Dwarf", "Elf", "Gnome", "HalfElf", "Halfling", "Halforc", "Human", "Tiefling"};
|
||||
|
||||
for (int i = 0; i <raceOptions.length; i++) {
|
||||
|
||||
raceBtnPanel.add(createButton(raceOptions[i]));
|
||||
|
||||
}
|
||||
|
||||
return raceBtnPanel;
|
||||
|
||||
}
|
||||
|
||||
private void panelSetup() {
|
||||
|
||||
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));
|
||||
|
||||
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);
|
||||
private JPanel createNavPanel() {
|
||||
|
||||
JTextPane textPane = new JTextPane();
|
||||
textPane.setBounds(47, 67, 223, 301);
|
||||
racePanel.add(textPane);
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBackground(new Color(205, 133, 63));
|
||||
|
||||
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) {
|
||||
}
|
||||
});
|
||||
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);
|
||||
panel.add(backButton);
|
||||
panel.add(continueButton);
|
||||
|
||||
return panel;
|
||||
|
||||
}
|
||||
|
||||
private JButton createButton(String raceName) {
|
||||
|
||||
JButton button = new JButton(raceName);
|
||||
button.addActionListener(
|
||||
|
||||
e -> raceChoice = raceName
|
||||
|
||||
);
|
||||
|
||||
return button;
|
||||
|
||||
}
|
||||
|
||||
public String getRaceChoice() {
|
||||
|
||||
return raceChoice;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 6.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 8.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 9.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 8.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 8.6 KiB |
Reference in New Issue
Block a user