refactoring GUI panels and adding race images.
This commit is contained in:
@@ -1,11 +1,13 @@
|
|||||||
package GUI;
|
package GUI;
|
||||||
|
|
||||||
|
import Character.AbilityScores.Stats;
|
||||||
|
import Character.Classes.*;
|
||||||
|
import Character.Races.*;
|
||||||
import GUI.Panels.*;
|
import GUI.Panels.*;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.*;
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
|
|
||||||
/* private void getNextPanel() {
|
/* private void getNextPanel() {
|
||||||
|
|
||||||
@@ -62,7 +64,7 @@ public class GUImanager extends JFrame {
|
|||||||
|
|
||||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
setPreferredSize(new Dimension(735,550));
|
setPreferredSize(new Dimension(730,550));
|
||||||
setSize(getPreferredSize());
|
setSize(getPreferredSize());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -98,7 +100,6 @@ public class GUImanager extends JFrame {
|
|||||||
new ActionListener() {
|
new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
System.out.println("Back button registered.");
|
|
||||||
|
|
||||||
lastPanel--;
|
lastPanel--;
|
||||||
currentPanel--;
|
currentPanel--;
|
||||||
@@ -122,7 +123,7 @@ public class GUImanager extends JFrame {
|
|||||||
new ActionListener() {
|
new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
System.out.println("Continue button registered.");
|
|
||||||
lastPanel++;
|
lastPanel++;
|
||||||
currentPanel++;
|
currentPanel++;
|
||||||
nextPanel++;
|
nextPanel++;
|
||||||
@@ -135,6 +136,60 @@ public class GUImanager extends JFrame {
|
|||||||
|
|
||||||
return button;
|
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() {
|
private void clearAndReset() {
|
||||||
|
|||||||
@@ -1,67 +1,110 @@
|
|||||||
package GUI.Panels;
|
package GUI.Panels;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.*;
|
||||||
import java.awt.Color;
|
import java.awt.event.*;
|
||||||
import java.awt.Font;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.*;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.border.*;
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.SwingConstants;
|
|
||||||
import javax.swing.border.BevelBorder;
|
|
||||||
import javax.swing.JTextPane;
|
|
||||||
|
|
||||||
public class ChooseRacePanel extends JPanel {
|
public class ChooseRacePanel extends JPanel {
|
||||||
|
|
||||||
|
private String raceChoice;
|
||||||
|
private JButton backButton;
|
||||||
|
private JButton continueButton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the panel.
|
* Create the panel.
|
||||||
*/
|
*/
|
||||||
public ChooseRacePanel(JButton backButton, JButton continueButton) {
|
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));
|
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));
|
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));
|
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();
|
private JPanel createNavPanel() {
|
||||||
racePanel.setOpaque(false);
|
|
||||||
add(racePanel, BorderLayout.CENTER);
|
|
||||||
racePanel.setLayout(null);
|
|
||||||
|
|
||||||
JTextPane textPane = new JTextPane();
|
JPanel panel = new JPanel();
|
||||||
textPane.setBounds(47, 67, 223, 301);
|
panel.setBackground(new Color(205, 133, 63));
|
||||||
racePanel.add(textPane);
|
|
||||||
|
|
||||||
JPanel raceBtnPanel = new JPanel();
|
panel.add(backButton);
|
||||||
raceBtnPanel.setBackground(new Color(165, 42, 42));
|
panel.add(continueButton);
|
||||||
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);
|
|
||||||
|
|
||||||
|
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