Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Deliverables . app.java (initial application) MainFrame.java (external JFrame .

ID: 3757091 • Letter: D

Question


Deliverables . app.java (initial application) MainFrame.java (external JFrame . A Java class for the control panel, that will ontain the 2 new panels, using a layout . A Java class for the Panel that will display the group's name and group's average GPA . A Java class for the Panel that will display names and semester GPAs of the 4 students in a group. groupjava and student java (a working version from previous labs, no changes needed. . Students should apply consistent indenting in all submissions. This can be done via the Contents You will start with a working version from the previous lab. All requirements are still the same including "You will create only one group object g 1 in this assignment. There will be only one statement group gl . new group..); in the whole application." Additional requirements are below. The Actionlistener will be implemented in the ControlPanel, the external panel that containg the other tworpanels A panel with 3 buttons displaying from a group object Uses the delault layout A panel with 4 buttom with student's semester GMs eracted from a grop Uses a grd layout The 4 buttons wil be listened to and they will dnglay the recalculated GPA when they are dicked

Explanation / Answer

import java.awt.BorderLayout;

import java.awt.EventQueue;

import javax.swing.JFrame;

import javax.swing.JPanel;

import javax.swing.border.EmptyBorder;

import javax.swing.JTextField;

import javax.swing.JButton;

import java.awt.event.ActionListener;

import java.awt.event.ActionEvent;

public class Threading extends JFrame {

    private JPanel contentPane;

    private JTextField DisplayOne;

    private JTextField DisplayTwo;

    int count;

    int count1;

    int count2;

    /**

     * Launch the application.

     */

    public static void main(String[] args) {

        EventQueue.invokeLater(new Runnable() {

            public void run()

            {

                  try {

                    Threading frame = new Threading();

                    frame.setVisible(true);

                } catch (Exception e) {

                    e.printStackTrace();

                }

            }

        });

    }

    /**

     * Create the frame.

     */

    public Threading()

    {

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        setBounds(100, 100, 450, 300);

        contentPane = new JPanel();

        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));

        contentPane.setLayout(new BorderLayout(0, 0));

        setContentPane(contentPane);

        JPanel panel = new JPanel();

        contentPane.add(panel, BorderLayout.CENTER);

        DisplayOne = new JTextField();

        panel.add(DisplayOne);

        DisplayOne.setColumns(10);

        DisplayTwo = new JTextField();

        panel.add(DisplayTwo);

        DisplayTwo.setColumns(10);

        JButton btnCountOne = new JButton("Count 1");

        count1=0;

        btnCountOne.addActionListener(new ActionListener() {               

                public void actionPerformed(ActionEvent arg0)

                {  

                    DisplayOne.setText(Integer.toString(count1++));

                }

        });

        panel.add(btnCountOne);

        JButton btnCountTwo = new JButton("Count 2");

        count2=0;

        btnCountTwo.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0)

            {

                DisplayTwo.setText(Integer.toString(count2++));

            }

        });

        panel.add(btnCountTwo);

        JButton btnCountBoth = new JButton("Count Both");

        count=0;

        btnCountBoth.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0)

            {

                while (count < 10)

                {

                DisplayOne.setText(Integer.toString(++count));

                DisplayTwo.setText(Integer.toString(count));

                }

            }

        });

        panel.add(btnCountBoth);

    }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote