Write Java FX code for this pseudocode of the void initilizaHistoryList() function. (HistoryMenu
of a game)
initializeHistoryList() : void
Purpose: To show the history of all players who logged in or played as guests. It will deserialize
Player objects, get desired info from its History object and then serialize the Player object.
Called by the constructor.
Pseudocode:
Ask user to to select opponent player vs player, player vs computer,view history, or quit.
User clicks on \"View History\"
initizalizeHistoryList() is called and a list of the Player object values from the Player map is
loaded into a variable
The list of Player objects is returned
Solution
package players;
import java.awt.EventQueue;
import javax.swing.ButtonGroup;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.JButton;
importjavax.swing.text.StyleContext.SmallAttributeSet;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
publicclassPlayerMain {
private JFrame frame;
private JTextField textField;
private JTextField textField_1;
private JTextField textField_2;
private JRadioButton rdbtnNewRadioButton;
private JRadioButton rdbtnComputer;
publicstatic Map pMap = new HashMap();
/**
* Launch the application.
*/
publicstaticvoidmain(String[] args) {
EventQueue.invokeLater(new Runnable() {
publicvoid run() {
try {
PlayerMain window = new PlayerMain();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
publicPlayerMain() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
privatevoid initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 511, 363);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JPanel panel = new JPanel();
panel.setBounds(0, 0, 495, 325);
frame.getContentPane().add(panel);
panel.setLayout(null);
JLabel lblNewLabel = new JLabel(\"Players History\");
lblNewLabel.setFont(new Font(\"Times New Roman\", Font.PLAIN, 24));
lblNewLabel.setBounds(182, 24, 155, 43);
panel.add(lblNewLabel);
JLabel lblPlayerName = new JLabel(\"Player Name :\");
lblPlayerName.setBounds(92, 99, 106, 14);
panel.add(lblPlayerName);
JLabel lblPlayerId = new JLabel(\"Player Id :\");
lblPlayerId.setBounds(92, 124, 106, 14);
panel.add(lblPlayerId);
JLabel lblPlayerAge = new JLabel(\"Player Age :\");
lblPlayerAge.setBounds(92, 149, 106, 14);
panel.add(lblPlayerAge);
rdbtnNewRadioButton = new JRadioButton(\"player\",true);
rdbtnNewRadioButton.setMnemonic(KeyEvent.VK_0);
rdbtnNewRadioButton.setBounds(151, 196, 71, 23);
rdbtnComputer = new JRadioButton(\"computer\");
rdbtnNewRadioButton.setMnemonic(KeyEvent.VK_1);
rdbtnComputer.setBounds(247, 196, 109, 23);
//Group the radio buttons.
ButtonG.
Write Java FX code for this pseudocode of the void initilizaHistoryL.pdf
1. Write Java FX code for this pseudocode of the void initilizaHistoryList() function. (HistoryMenu
of a game)
initializeHistoryList() : void
Purpose: To show the history of all players who logged in or played as guests. It will deserialize
Player objects, get desired info from its History object and then serialize the Player object.
Called by the constructor.
Pseudocode:
Ask user to to select opponent player vs player, player vs computer,view history, or quit.
User clicks on "View History"
initizalizeHistoryList() is called and a list of the Player object values from the Player map is
loaded into a variable
The list of Player objects is returned
Solution
package players;
import java.awt.EventQueue;
import javax.swing.ButtonGroup;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.JButton;
importjavax.swing.text.StyleContext.SmallAttributeSet;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
publicclassPlayerMain {
private JFrame frame;