I have the following problem:
For Java GUI project, you will implement a simple Character Creation Screen as found in many
different RPGs (role playing games.) This screen will allow the user to pick and save a
character’s specifications from a list of options.
The interface must have the following:
(Radio Buttons) The user may select among three options for the character’s Gender:
Male
Female
Hermaphrodite
(A Drop-Down List) The user may select from among the following Professions for the
character:
Warrior, Barbarian, Monk, Mage, Thief
(A Text Field) The user may enter his/her character’s Name, which must be at least one character
long, but may be as long as 10 characters
(Sliders and a label) The user has 100 skill points to spend across 4 different passive skills. The
user will see a label with “100” on it originally. o Whenever he/she slides a slider to increase the
skill points in that skill, the points are taken from the 100 points (or however many are
remaining.)
When the user decreases the skill points in a particular area, they are returned to the “points left
to spend” pool, and this is reflected in the label as well. The remaining points will always be
displayed in this label.
If the player runs out of points to spend, he/she should not be able to increase the points in any
skill area until points are returned to the pool, and are available to be spent
The four (4) skill areas are as follows:
Intelligence, Dexterity, Strength, and Wisdom
There will be a Menu System for opening and saving a saved character.
The menu bar should contain two titles: File and Options
Under the File Menu, there are two options:
Open a saved character
Save a character
Under the Options Menu, there are two options:
Reset All
Exit File
Open (a Saved Character)
With this option, you should be able to open a saved character file, for example, Bob.player or
Sue.player
The character’s information will be read into the program and all the components on the GUI
will be set accordingly, as if the user had just entered them. If the user makes changes, these
changes should overwrite the current file (upon a save.)
File Save (a Character)
This option allows the user to save the current player he/she is working on. The file will contain
information that represents the state of the GUI and must be readable by the Open option. The
file must be saved as character_name.player.
You should prompt the user and say “Are you sure you want to save this charcter?” before they
actually save it. Your dialog prompt should allow the user to Cancel the save if he/she so desires.
Reset All
Reset All sets all the GUI components to their zero state. Note that this option does not
automatically save the character data.
Exit
This is self-explanatory. Close the Character Creation application.
How do you I do this with the following code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JOptionPane;
import java.io.*;
import java.util.*;
public class Char.
I have the following problemFor Java GUI project, you will implem.pdf
1. I have the following problem:
For Java GUI project, you will implement a simple Character Creation Screen as found in many
different RPGs (role playing games.) This screen will allow the user to pick and save a
character’s specifications from a list of options.
The interface must have the following:
(Radio Buttons) The user may select among three options for the character’s Gender:
Male
Female
Hermaphrodite
(A Drop-Down List) The user may select from among the following Professions for the
character:
Warrior, Barbarian, Monk, Mage, Thief
(A Text Field) The user may enter his/her character’s Name, which must be at least one character
long, but may be as long as 10 characters
(Sliders and a label) The user has 100 skill points to spend across 4 different passive skills. The
user will see a label with “100” on it originally. o Whenever he/she slides a slider to increase the
skill points in that skill, the points are taken from the 100 points (or however many are
remaining.)
When the user decreases the skill points in a particular area, they are returned to the “points left
to spend” pool, and this is reflected in the label as well. The remaining points will always be
displayed in this label.
If the player runs out of points to spend, he/she should not be able to increase the points in any
skill area until points are returned to the pool, and are available to be spent
The four (4) skill areas are as follows:
Intelligence, Dexterity, Strength, and Wisdom
There will be a Menu System for opening and saving a saved character.
The menu bar should contain two titles: File and Options
Under the File Menu, there are two options:
Open a saved character
Save a character
Under the Options Menu, there are two options:
Reset All
Exit File
Open (a Saved Character)
2. With this option, you should be able to open a saved character file, for example, Bob.player or
Sue.player
The character’s information will be read into the program and all the components on the GUI
will be set accordingly, as if the user had just entered them. If the user makes changes, these
changes should overwrite the current file (upon a save.)
File Save (a Character)
This option allows the user to save the current player he/she is working on. The file will contain
information that represents the state of the GUI and must be readable by the Open option. The
file must be saved as character_name.player.
You should prompt the user and say “Are you sure you want to save this charcter?” before they
actually save it. Your dialog prompt should allow the user to Cancel the save if he/she so desires.
Reset All
Reset All sets all the GUI components to their zero state. Note that this option does not
automatically save the character data.
Exit
This is self-explanatory. Close the Character Creation application.
How do you I do this with the following code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JOptionPane;
import java.io.*;
import java.util.*;
public class Character extends JFrame
{
//Constants for window width and height
private final int WINDOW_WIDTH = 1500;
private final int WINDOW_HEIGHT = 250;
//Character gender
private JRadioButton male;
private JRadioButton female;
private JRadioButton hermaphrodite ;
//Character Name and Class
private JTextField characterName;
private JComboBox proffesion;
4. //Adding the panel to JFrame
add(gender);
add(namePanel);
add(intelPanel);
add(dexPanel);
add(strengthPanel);
add(wisdomPanel);
//Visibility
setVisible(true);
// Creates a menubar for a JFrame
JMenuBar menuBar = new JMenuBar();
// Add the menubar to the frame
setJMenuBar(menuBar);
// Define and add two drop down menu to the menubar
JMenu fileMenu = new JMenu("File");
JMenu editMenu = new JMenu("Option");
menuBar.add(fileMenu);
menuBar.add(editMenu);
// Create and add simple menu item to one of the drop down menu
JMenuItem resetAction = new JMenuItem("Reset all");
JMenuItem openAction = new JMenuItem("Open a saved character");
JMenuItem exitAction = new JMenuItem("Exit");
JMenuItem saveAction = new JMenuItem("Save");
// Create a Menu ButtonGroup
ButtonGroup bg = new ButtonGroup();
fileMenu.add(openAction);
fileMenu.add(saveAction);
editMenu.add(resetAction);
editMenu.add(exitAction);
5. // Create JSLider
JSlider intelligence = new JSlider(JSlider.HORIZONTAL, 0, 100, 0);
JSlider dexterity = new JSlider(JSlider.HORIZONTAL, 0, 100, 0);
JSlider strength = new JSlider(JSlider.HORIZONTAL, 0, 100, 0);
JSlider wisdom = new JSlider(JSlider.HORIZONTAL, 0, 100, 0);
}
// Building the Panels,
private void buildPanels()
{
//Initializing butons
male = new JRadioButton("Male");
female = new JRadioButton("Female");
hermaphrodite = new JRadioButton("Hermaphrodite");
characterGender = new ButtonGroup();
characterGender.add(male);
characterGender.add(female);
characterGender.add(hermaphrodite);
//Initializing TextField and JComboBox
characterName = new JTextField(10);
String[] classes = { "Warrior", "Barbarian", "Monk", "Mage", "Thief" };
JComboBox proffesion = new JComboBox(classes);
//Initializing JSlider
intelligence = new JSlider();
dexterity = new JSlider();
strength = new JSlider();
wisdom = new JSlider();
//Initializing the panels
gender = new JPanel();
6. namePanel = new JPanel();
intelPanel = new JPanel();
dexPanel = new JPanel();
strengthPanel= new JPanel();
wisdomPanel = new JPanel();
//Setting borders of the panels
gender.setBorder(BorderFactory.createTitledBorder("Gender"));
namePanel.setBorder(BorderFactory.createTitledBorder("Name and Class"));
intelPanel.setBorder(BorderFactory.createTitledBorder("Intelligence"));
dexPanel.setBorder(BorderFactory.createTitledBorder("Dexterity"));
strengthPanel.setBorder(BorderFactory.createTitledBorder("Strength"));
wisdomPanel.setBorder(BorderFactory.createTitledBorder("Wisdom"));
//Adding the objecs to the respective panels
gender.add(male);
gender.add(female);
gender.add(hermaphrodite);
namePanel.add(characterName);
namePanel.add(proffesion);
//Creating Stats and
int startValue = 0;
intelPanel.add(intelligence);
intelligence.setValue(startValue);
intelligence.setMajorTickSpacing(25);
intelligence.setMinorTickSpacing(25);
intelligence.setPaintTicks(true);
intelligence.setPaintLabels(true);
dexPanel.add(dexterity);
dexterity.setValue(startValue);
dexterity.setMajorTickSpacing(25);
dexterity.setMinorTickSpacing(25);