SlideShare a Scribd company logo
1 of 7
Download to read offline
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.
ButtonGroup group = new ButtonGroup();
group.add(rdbtnNewRadioButton);
group.add(rdbtnComputer);
panel.add(rdbtnComputer);
panel.add(rdbtnNewRadioButton);
textField = new JTextField();
textField.setBounds(182, 96, 144, 20);
panel.add(textField);
textField.setColumns(10);
textField_1 = new JTextField();
textField_1.setBounds(182, 121, 144, 20);
panel.add(textField_1);
textField_1.setColumns(10);
textField_2 = new JTextField();
textField_2.setBounds(180, 149, 144, 20);
panel.add(textField_2);
textField_2.setColumns(10);
JButton btnSubmit = new JButton("submit");
btnSubmit.addMouseListener(new MouseAdapter() {
@Override
publicvoid mouseClicked(MouseEvent arg0) {
if(textField_1.getText() !=null){
Player player = new Player();
player.setpName(textField.getText());
player.setpAge(textField_2.getText());
player.setpId(textField_1.getText());
if(rdbtnNewRadioButton.isSelected()){
player.setpOppent("player");
}else{
player.setpOppent("computer");
}
pMap.put(player.getpId(), player);
}
}
});
btnSubmit.setBounds(130, 249, 89, 23);
panel.add(btnSubmit);
JButton btnViewHistory = new JButton("view History");
btnViewHistory.addMouseListener(new MouseAdapter() {
@Override
publicvoid mouseClicked(MouseEvent arg0) {
List playersList = initilizaHistoryList();
ViewHistory viewHistory= new ViewHistory(playersList);
}
});
btnViewHistory.setBounds(248, 249, 121, 23);
panel.add(btnViewHistory);
}
public List initilizaHistoryList() {
List players= new ArrayList();
List list = new ArrayList(pMap.values());
players.addAll(list);
return players;
}
}
package players;
import java.util.List;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextPane;
public class ViewHistory {
private JFrame frame;
/**
* Create the application.
*/
public ViewHistory(List players) {
initialize(players);
}
/**
* Initialize the contents of the frame.
*/
private void initialize(List players) {
frame = new JFrame();
frame.setBounds(100, 100, 450, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JPanel panel = new JPanel();
panel.setBounds(0, 0, 434, 262);
frame.getContentPane().add(panel);
panel.setLayout(null);
JTextPane textPane = new JTextPane();
textPane.setText("");
textPane.setBounds(10, 11, 414, 240);
panel.add(textPane);
if(players !=null && players.size()>0){
textPane.setText(players.toString());
}else{
textPane.setText("No players logged....................");
}
frame.setVisible(true);
}
}
package players;
publicclassPlayer {
private String pName;
private String pId;
private String pAge;
private String pOppent;
public String getpName() {
return pName;
}
publicvoidsetpName(String pName) {
this.pName = pName;
}
public String getpId() {
return pId;
}
publicvoidsetpId(String pId) {
this.pId = pId;
}
public String getpAge() {
return pAge;
}
publicvoidsetpAge(String pAge) {
this.pAge = pAge;
}
public String getpOppent() {
return pOppent;
}
publicvoidsetpOppent(String pOppent) {
this.pOppent = pOppent;
}
@Override
public String toString() {
return "PlayerName=" + pName + ",PlayerAge=" + pAge
+ ",PlayerOpponent=" + pOppent
+ " ";
}
}

More Related Content

Similar to Write Java FX code for this pseudocode of the void initilizaHistoryL.pdf

import java.awt.;import java.awt.event.;import javax.swing.;.pdf
import java.awt.;import java.awt.event.;import javax.swing.;.pdfimport java.awt.;import java.awt.event.;import javax.swing.;.pdf
import java.awt.;import java.awt.event.;import javax.swing.;.pdf
aoneonlinestore1
 
I hope the below code is helpful to you, please give me rewards.im.pdf
I hope the below code is helpful to you, please give me rewards.im.pdfI hope the below code is helpful to you, please give me rewards.im.pdf
I hope the below code is helpful to you, please give me rewards.im.pdf
apexelectronices01
 
Programming a guide gui
Programming a guide guiProgramming a guide gui
Programming a guide gui
Mahmoud Hikmet
 
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdfObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
rajkumarm401
 
Please help with this. program must be written in C# .. All of the g.pdf
Please help with this. program must be written in C# .. All of the g.pdfPlease help with this. program must be written in C# .. All of the g.pdf
Please help with this. program must be written in C# .. All of the g.pdf
manjan6
 
Quest 1 define a class batsman with the following specifications
Quest  1 define a class batsman with the following specificationsQuest  1 define a class batsman with the following specifications
Quest 1 define a class batsman with the following specifications
rajkumari873
 
Tic Tac Toe game with GUI written in java.SolutionAnswerimp.pdf
Tic Tac Toe game with GUI written in java.SolutionAnswerimp.pdfTic Tac Toe game with GUI written in java.SolutionAnswerimp.pdf
Tic Tac Toe game with GUI written in java.SolutionAnswerimp.pdf
infomalad
 
JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 Spring
Kiyotaka Oku
 
java code please Add event handlers to the buttons in your TicTacToe.pdf
java code please Add event handlers to the buttons in your TicTacToe.pdfjava code please Add event handlers to the buttons in your TicTacToe.pdf
java code please Add event handlers to the buttons in your TicTacToe.pdf
ezzi97
 
Enhance the ButtonViewer program so that it prints the time at which t.docx
Enhance the ButtonViewer program so that it prints the time at which t.docxEnhance the ButtonViewer program so that it prints the time at which t.docx
Enhance the ButtonViewer program so that it prints the time at which t.docx
todd401
 

Similar to Write Java FX code for this pseudocode of the void initilizaHistoryL.pdf (20)

import java.awt.;import java.awt.event.;import javax.swing.;.pdf
import java.awt.;import java.awt.event.;import javax.swing.;.pdfimport java.awt.;import java.awt.event.;import javax.swing.;.pdf
import java.awt.;import java.awt.event.;import javax.swing.;.pdf
 
I hope the below code is helpful to you, please give me rewards.im.pdf
I hope the below code is helpful to you, please give me rewards.im.pdfI hope the below code is helpful to you, please give me rewards.im.pdf
I hope the below code is helpful to you, please give me rewards.im.pdf
 
Programming a guide gui
Programming a guide guiProgramming a guide gui
Programming a guide gui
 
WP7 HUB_XNA
WP7 HUB_XNAWP7 HUB_XNA
WP7 HUB_XNA
 
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdfObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
 
import java.util.Scanner; import java.util.Random; public clas.pdf
import java.util.Scanner; import java.util.Random; public clas.pdfimport java.util.Scanner; import java.util.Random; public clas.pdf
import java.util.Scanner; import java.util.Random; public clas.pdf
 
SenchaCon 2016: Keynote Presentation - Art Landro, Gautam Agrawal, Mark Brocato
SenchaCon 2016: Keynote Presentation - Art Landro, Gautam Agrawal, Mark BrocatoSenchaCon 2016: Keynote Presentation - Art Landro, Gautam Agrawal, Mark Brocato
SenchaCon 2016: Keynote Presentation - Art Landro, Gautam Agrawal, Mark Brocato
 
Please help with this. program must be written in C# .. All of the g.pdf
Please help with this. program must be written in C# .. All of the g.pdfPlease help with this. program must be written in C# .. All of the g.pdf
Please help with this. program must be written in C# .. All of the g.pdf
 
ch20.pptx
ch20.pptxch20.pptx
ch20.pptx
 
Quest 1 define a class batsman with the following specifications
Quest  1 define a class batsman with the following specificationsQuest  1 define a class batsman with the following specifications
Quest 1 define a class batsman with the following specifications
 
Tic Tac Toe game with GUI written in java.SolutionAnswerimp.pdf
Tic Tac Toe game with GUI written in java.SolutionAnswerimp.pdfTic Tac Toe game with GUI written in java.SolutionAnswerimp.pdf
Tic Tac Toe game with GUI written in java.SolutionAnswerimp.pdf
 
Modern Android Architecture
Modern Android ArchitectureModern Android Architecture
Modern Android Architecture
 
JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 Spring
 
CreateJS
CreateJSCreateJS
CreateJS
 
Sequencing Audio Using React and the Web Audio API
Sequencing Audio Using React and the Web Audio APISequencing Audio Using React and the Web Audio API
Sequencing Audio Using React and the Web Audio API
 
java code please Add event handlers to the buttons in your TicTacToe.pdf
java code please Add event handlers to the buttons in your TicTacToe.pdfjava code please Add event handlers to the buttons in your TicTacToe.pdf
java code please Add event handlers to the buttons in your TicTacToe.pdf
 
Creating a Facebook Clone - Part XVI.pdf
Creating a Facebook Clone - Part XVI.pdfCreating a Facebook Clone - Part XVI.pdf
Creating a Facebook Clone - Part XVI.pdf
 
XNA coding series
XNA coding seriesXNA coding series
XNA coding series
 
Html5 game, websocket e arduino
Html5 game, websocket e arduinoHtml5 game, websocket e arduino
Html5 game, websocket e arduino
 
Enhance the ButtonViewer program so that it prints the time at which t.docx
Enhance the ButtonViewer program so that it prints the time at which t.docxEnhance the ButtonViewer program so that it prints the time at which t.docx
Enhance the ButtonViewer program so that it prints the time at which t.docx
 

More from sales98

Genetic evidence supports which of the following explanations for the.pdf
Genetic evidence supports which of the following explanations for the.pdfGenetic evidence supports which of the following explanations for the.pdf
Genetic evidence supports which of the following explanations for the.pdf
sales98
 
Evolution is driven by environmental that put selection pressure on o.pdf
Evolution is driven by environmental that put selection pressure on o.pdfEvolution is driven by environmental that put selection pressure on o.pdf
Evolution is driven by environmental that put selection pressure on o.pdf
sales98
 
e) As a practical matter, trade-offs of qualitative characteristics o.pdf
e) As a practical matter, trade-offs of qualitative characteristics o.pdfe) As a practical matter, trade-offs of qualitative characteristics o.pdf
e) As a practical matter, trade-offs of qualitative characteristics o.pdf
sales98
 
Define the role of the entrepreneur in the U.S. economy and describe.pdf
Define the role of the entrepreneur in the U.S. economy and describe.pdfDefine the role of the entrepreneur in the U.S. economy and describe.pdf
Define the role of the entrepreneur in the U.S. economy and describe.pdf
sales98
 
Consider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdfConsider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdf
sales98
 
alter ego theory. TRUE FALSE Multiple Choice her nephew Dru to manag.pdf
alter ego theory. TRUE FALSE Multiple Choice her nephew Dru to manag.pdfalter ego theory. TRUE FALSE Multiple Choice her nephew Dru to manag.pdf
alter ego theory. TRUE FALSE Multiple Choice her nephew Dru to manag.pdf
sales98
 
2)Are enterprise information portals making executive information sy.pdf
2)Are enterprise information portals making executive information sy.pdf2)Are enterprise information portals making executive information sy.pdf
2)Are enterprise information portals making executive information sy.pdf
sales98
 
Why is it that ozone is not desirable at the surface of earth, but i.pdf
Why is it that ozone is not desirable at the surface of earth, but i.pdfWhy is it that ozone is not desirable at the surface of earth, but i.pdf
Why is it that ozone is not desirable at the surface of earth, but i.pdf
sales98
 
Write a program that moves the ball in a pane. You should define a p.pdf
Write a program that moves the ball in a pane. You should define a p.pdfWrite a program that moves the ball in a pane. You should define a p.pdf
Write a program that moves the ball in a pane. You should define a p.pdf
sales98
 
What are the limitations of an expert systemSolutionLIMITATIO.pdf
What are the limitations of an expert systemSolutionLIMITATIO.pdfWhat are the limitations of an expert systemSolutionLIMITATIO.pdf
What are the limitations of an expert systemSolutionLIMITATIO.pdf
sales98
 

More from sales98 (20)

Genetic evidence supports which of the following explanations for the.pdf
Genetic evidence supports which of the following explanations for the.pdfGenetic evidence supports which of the following explanations for the.pdf
Genetic evidence supports which of the following explanations for the.pdf
 
Complete the following table for InvestmentsFair value method(s).pdf
Complete the following table for InvestmentsFair value method(s).pdfComplete the following table for InvestmentsFair value method(s).pdf
Complete the following table for InvestmentsFair value method(s).pdf
 
Find the values of the trigonometric functions of from the informat.pdf
Find the values of the trigonometric functions of  from the informat.pdfFind the values of the trigonometric functions of  from the informat.pdf
Find the values of the trigonometric functions of from the informat.pdf
 
Evolution is driven by environmental that put selection pressure on o.pdf
Evolution is driven by environmental that put selection pressure on o.pdfEvolution is driven by environmental that put selection pressure on o.pdf
Evolution is driven by environmental that put selection pressure on o.pdf
 
e) As a practical matter, trade-offs of qualitative characteristics o.pdf
e) As a practical matter, trade-offs of qualitative characteristics o.pdfe) As a practical matter, trade-offs of qualitative characteristics o.pdf
e) As a practical matter, trade-offs of qualitative characteristics o.pdf
 
Determine whether the relation defines y as a function of x. Give the.pdf
Determine whether the relation defines y as a function of x. Give the.pdfDetermine whether the relation defines y as a function of x. Give the.pdf
Determine whether the relation defines y as a function of x. Give the.pdf
 
Connor and his wife are guests at the hotel, having reserved a room .pdf
Connor and his wife are guests at the hotel, having reserved a room .pdfConnor and his wife are guests at the hotel, having reserved a room .pdf
Connor and his wife are guests at the hotel, having reserved a room .pdf
 
Define the role of the entrepreneur in the U.S. economy and describe.pdf
Define the role of the entrepreneur in the U.S. economy and describe.pdfDefine the role of the entrepreneur in the U.S. economy and describe.pdf
Define the role of the entrepreneur in the U.S. economy and describe.pdf
 
Consider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdfConsider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdf
 
8. You may have heard that drinking soda or acid is bad for your teet.pdf
8. You may have heard that drinking soda or acid is bad for your teet.pdf8. You may have heard that drinking soda or acid is bad for your teet.pdf
8. You may have heard that drinking soda or acid is bad for your teet.pdf
 
alter ego theory. TRUE FALSE Multiple Choice her nephew Dru to manag.pdf
alter ego theory. TRUE FALSE Multiple Choice her nephew Dru to manag.pdfalter ego theory. TRUE FALSE Multiple Choice her nephew Dru to manag.pdf
alter ego theory. TRUE FALSE Multiple Choice her nephew Dru to manag.pdf
 
2)Are enterprise information portals making executive information sy.pdf
2)Are enterprise information portals making executive information sy.pdf2)Are enterprise information portals making executive information sy.pdf
2)Are enterprise information portals making executive information sy.pdf
 
5. How the tax system changes the distribution of income among capita.pdf
5. How the tax system changes the distribution of income among capita.pdf5. How the tax system changes the distribution of income among capita.pdf
5. How the tax system changes the distribution of income among capita.pdf
 
Your name Date Explanation of Program -Modifying the first .pdf
Your name Date  Explanation of Program -Modifying the first .pdfYour name Date  Explanation of Program -Modifying the first .pdf
Your name Date Explanation of Program -Modifying the first .pdf
 
Why is it that ozone is not desirable at the surface of earth, but i.pdf
Why is it that ozone is not desirable at the surface of earth, but i.pdfWhy is it that ozone is not desirable at the surface of earth, but i.pdf
Why is it that ozone is not desirable at the surface of earth, but i.pdf
 
Write a program that moves the ball in a pane. You should define a p.pdf
Write a program that moves the ball in a pane. You should define a p.pdfWrite a program that moves the ball in a pane. You should define a p.pdf
Write a program that moves the ball in a pane. You should define a p.pdf
 
Which ape has been known to make territory patrols and wage war o.pdf
Which ape has been known to make territory patrols and wage war o.pdfWhich ape has been known to make territory patrols and wage war o.pdf
Which ape has been known to make territory patrols and wage war o.pdf
 
What are the limitations of an expert systemSolutionLIMITATIO.pdf
What are the limitations of an expert systemSolutionLIMITATIO.pdfWhat are the limitations of an expert systemSolutionLIMITATIO.pdf
What are the limitations of an expert systemSolutionLIMITATIO.pdf
 
Using the scenario provided in the Milestone One Guidelines and Rubr.pdf
Using the scenario provided in the Milestone One Guidelines and Rubr.pdfUsing the scenario provided in the Milestone One Guidelines and Rubr.pdf
Using the scenario provided in the Milestone One Guidelines and Rubr.pdf
 
To avoid crises, companies should design their organizations to impl.pdf
To avoid crises, companies should design their organizations to impl.pdfTo avoid crises, companies should design their organizations to impl.pdf
To avoid crises, companies should design their organizations to impl.pdf
 

Recently uploaded

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Recently uploaded (20)

Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 

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;
  • 2. 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);
  • 3. 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. ButtonGroup group = new ButtonGroup(); group.add(rdbtnNewRadioButton); group.add(rdbtnComputer); panel.add(rdbtnComputer);
  • 4. panel.add(rdbtnNewRadioButton); textField = new JTextField(); textField.setBounds(182, 96, 144, 20); panel.add(textField); textField.setColumns(10); textField_1 = new JTextField(); textField_1.setBounds(182, 121, 144, 20); panel.add(textField_1); textField_1.setColumns(10); textField_2 = new JTextField(); textField_2.setBounds(180, 149, 144, 20); panel.add(textField_2); textField_2.setColumns(10); JButton btnSubmit = new JButton("submit"); btnSubmit.addMouseListener(new MouseAdapter() { @Override publicvoid mouseClicked(MouseEvent arg0) { if(textField_1.getText() !=null){ Player player = new Player(); player.setpName(textField.getText()); player.setpAge(textField_2.getText()); player.setpId(textField_1.getText()); if(rdbtnNewRadioButton.isSelected()){ player.setpOppent("player"); }else{ player.setpOppent("computer"); } pMap.put(player.getpId(), player); }
  • 5. } }); btnSubmit.setBounds(130, 249, 89, 23); panel.add(btnSubmit); JButton btnViewHistory = new JButton("view History"); btnViewHistory.addMouseListener(new MouseAdapter() { @Override publicvoid mouseClicked(MouseEvent arg0) { List playersList = initilizaHistoryList(); ViewHistory viewHistory= new ViewHistory(playersList); } }); btnViewHistory.setBounds(248, 249, 121, 23); panel.add(btnViewHistory); } public List initilizaHistoryList() { List players= new ArrayList(); List list = new ArrayList(pMap.values()); players.addAll(list); return players; } } package players; import java.util.List; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextPane; public class ViewHistory { private JFrame frame; /** * Create the application. */ public ViewHistory(List players) {
  • 6. initialize(players); } /** * Initialize the contents of the frame. */ private void initialize(List players) { frame = new JFrame(); frame.setBounds(100, 100, 450, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(null); JPanel panel = new JPanel(); panel.setBounds(0, 0, 434, 262); frame.getContentPane().add(panel); panel.setLayout(null); JTextPane textPane = new JTextPane(); textPane.setText(""); textPane.setBounds(10, 11, 414, 240); panel.add(textPane); if(players !=null && players.size()>0){ textPane.setText(players.toString()); }else{ textPane.setText("No players logged...................."); } frame.setVisible(true); } } package players; publicclassPlayer { private String pName;
  • 7. private String pId; private String pAge; private String pOppent; public String getpName() { return pName; } publicvoidsetpName(String pName) { this.pName = pName; } public String getpId() { return pId; } publicvoidsetpId(String pId) { this.pId = pId; } public String getpAge() { return pAge; } publicvoidsetpAge(String pAge) { this.pAge = pAge; } public String getpOppent() { return pOppent; } publicvoidsetpOppent(String pOppent) { this.pOppent = pOppent; } @Override public String toString() { return "PlayerName=" + pName + ",PlayerAge=" + pAge + ",PlayerOpponent=" + pOppent + " "; } }