Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

PLEASE TYPE ONLY IF NOT TYPE THAN DO NOT DO THIS****

PLEASE FOLLOW THE CODE BELOW AND CODE ACCORD TO THAT***

 

 

 

An example of the JFrame subclass with main method is as follows:

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

 

public class NBAPlayoff extends JFrame  {

       private JTextField txtName;

       private JTextField txtAge;

       private  NBATeam spurs;

       private NBAcourtPanel court;

       private JLabel lMax, lMin, lAvg, lNum;

            

       public NBAPlayoff(){

            spurs=new NBATeam("Spurs");

            court=new NBAcourtPanel(spurs);

            add(court, BorderLayout.CENTER);

           

            JLabel lMax0=new JLabel("Max Age:");

            lMax=new JLabel("");

            JLabel lMin0=new JLabel("Min Age:");

            lMin=new JLabel("");

            JLabel lAvg0=new JLabel("Average Age:");

            lAvg=new JLabel("");

            JLabel lNum0=new JLabel("Number of Players:");

            lNum =new JLabel("");

            JPanel rp=new JPanel(new GridLayout(8, 1)); //right panel

            rp.add(lNum0);rp.add(lNum);rp.add(lMax0);rp.add(lMax);

            rp.add(lMin0);rp.add(lMin);rp.add(lAvg0);rp.add(lAvg);

            add(rp, BorderLayout.EAST);

                   

            JLabel l1=new JLabel("Player Name:");

            txtName= new JTextField();

            txtName.setPreferredSize(new Dimension(120,24));

            JLabel l2=new JLabel("Player Age:");

            txtAge= new JTextField();

            txtAge.setPreferredSize(new Dimension(120,24));

           

            JButton jbtAdd=new JButton("Add A Player");

            jbtAdd.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {

                      int age=Integer.parseInt(txtAge.getText());

                      spurs.addAPlayer(txtName.getText(), age);

                      lMax.setText(spurs.getMaxAge()+"");

                      lMin.setText(spurs.getMinAge()+"");

                      lAvg.setText(spurs.getAvgAge()+"");

                      lNum.setText(spurs.getNumOfPlayer()+"");

                      

                      court.repaint();

                }});

           

            JButton jbtClear= new JButton("Clear");

            jbtClear.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {

                      txtName.setText("");

                      txtAge.setText("");

                }});

           

            JPanel pBot=new JPanel();

            pBot.add(l1); pBot.add(txtName); pBot.add(l2);pBot.add(txtAge); pBot.add(jbtAdd);pBot.add(jbtClear);

            add(pBot, BorderLayout.SOUTH);

 

 

       }

public static void main(String[] args) {

            

             NBAPlayoff frame = new NBAPlayoff();

              

            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            frame.setLocationRelativeTo(null);

            frame.setSize(800, 400);          

            frame.setVisible(true);

       }

}

Program #1:
Write a program to simulate showing an NBA Team on a Basketball court.
Here is an example of the screenshot when running the program:
-O|
Number of Players:
5
Max Age:
Tony Parker
K. Leonard
32
T. Splitter
Min Age:
T. Duncan
M. Ginobili
21
Average Age:
28
Player Name: M. Ginobili
Player Age: 32
Add A Player
Clear
expand button
Transcribed Image Text:Program #1: Write a program to simulate showing an NBA Team on a Basketball court. Here is an example of the screenshot when running the program: -O| Number of Players: 5 Max Age: Tony Parker K. Leonard 32 T. Splitter Min Age: T. Duncan M. Ginobili 21 Average Age: 28 Player Name: M. Ginobili Player Age: 32 Add A Player Clear
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education