In this lab you will add code to the given java file to produce a Javax.swing GUI very much like the image below in image       Use the ‘starter’ file, TestGUICounter.java For this lab, read my pseudocode in the given java files FIRST!! ANALYZE my code carefully. Then start coding the solution. I have given the solution to each lab instructor to help you during the time for your specific lab. PLEASE FINISH THE JAVA CODE AS GUIDED BY THE Slashed LINES   import java.awt.*; import java.awt.event.*; import javax.swing.*; public class TestGUICounter {     static JFrame frame_1;     static JButton start_val, add_1, minus_1, reset_1;     static JLabel label_1, label_num;     static JTextField text_1;     static JPanel panel_center, panel_south;     static int iCounter;          public static void main(String[] args) {         frame_1 = new JFrame();          frame_1.setLayout(new BorderLayout());          panel_center = new JPanel();         panel_south = new JPanel();         panel_center.setLayout(new FlowLayout());         panel_south.setLayout(new FlowLayout());         start_val = new JButton("Start Counter");         add_1 = new JButton("Add 1");         minus_1 = new JButton("Delete 1");         reset_1 = new JButton("Reset");         label_1 = new JLabel("Value is: ");                  // setup all buttons to use the "ButtonListener()" class for ActionEvents         // Put the JtextField, and the two JLabel in the 'panel_center'          // and the buttons in the 'panel_south' panels.         // add the two panels to the 'frame_1' in the proper          // area (CENTER, SOUTH, NORTH, EAST, WEST)                           frame_1.setSize(450, 200);             frame_1.setVisible(true);         frame_1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);     }     private static class ButtonListener implements ActionListener {         public void actionPerformed(ActionEvent e) {             // write code here to test which of the three buttons             // have been clicked using 'e.getSource().equals...'             // very similar to the demonstration I did in class lecture             // First, when 'start_val' clicked, then get the value from the 'text_1'             // text box (user 'getText()' method) and set the 'label_num' and the               // iCounter to be that value. Next, in the if 'add_1' clicked, then              // add 1 to the 'iCounter' and update label: 'label_num' and if             // the 'minus_1' is clicked, delete 1 from iCounter and update             // the 'label_num' Then, if 'reset_1' is clicked, set things blank and back to zero.             // HINT: when you get the value from a JTextField, it is a string, so              // you have to convert it to an integer to give the value to 'iCounter'             // and to convert an integer to a string, use 'Integer.parseInt(string variable)'             //                      }     } }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

In this lab you will add code to the given java file to produce a Javax.swing GUI very much like the image
below in image

 

 

 

Use the ‘starter’ file, TestGUICounter.java
For this lab, read my pseudocode in the given java files FIRST!!
ANALYZE my code carefully.
Then start coding the solution.
I have given the solution to each lab instructor to help you during the time for your specific lab.
PLEASE FINISH THE JAVA CODE AS GUIDED BY THE Slashed LINES

 

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class TestGUICounter {
    static JFrame frame_1;
    static JButton start_val, add_1, minus_1, reset_1;
    static JLabel label_1, label_num;
    static JTextField text_1;
    static JPanel panel_center, panel_south;
    static int iCounter;
    
    public static void main(String[] args) {
        frame_1 = new JFrame(); 
        frame_1.setLayout(new BorderLayout()); 
        panel_center = new JPanel();
        panel_south = new JPanel();
        panel_center.setLayout(new FlowLayout());
        panel_south.setLayout(new FlowLayout());
        start_val = new JButton("Start Counter");
        add_1 = new JButton("Add 1");
        minus_1 = new JButton("Delete 1");
        reset_1 = new JButton("Reset");
        label_1 = new JLabel("Value is: ");
        
        // setup all buttons to use the "ButtonListener()" class for ActionEvents
        // Put the JtextField, and the two JLabel in the 'panel_center' 
        // and the buttons in the 'panel_south' panels.
        // add the two panels to the 'frame_1' in the proper 
        // area (CENTER, SOUTH, NORTH, EAST, WEST)
        
        
        frame_1.setSize(450, 200);    
        frame_1.setVisible(true);
        frame_1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    private static class ButtonListener implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            // write code here to test which of the three buttons
            // have been clicked using 'e.getSource().equals...'
            // very similar to the demonstration I did in class lecture
            // First, when 'start_val' clicked, then get the value from the 'text_1'
            // text box (user 'getText()' method) and set the 'label_num' and the  
            // iCounter to be that value. Next, in the if 'add_1' clicked, then 
            // add 1 to the 'iCounter' and update label: 'label_num' and if
            // the 'minus_1' is clicked, delete 1 from iCounter and update
            // the 'label_num' Then, if 'reset_1' is clicked, set things blank and back to zero.
            // HINT: when you get the value from a JTextField, it is a string, so 
            // you have to convert it to an integer to give the value to 'iCounter'
            // and to convert an integer to a string, use 'Integer.parseInt(string variable)'
            //
            
        }

    }
}

 

Value is: 0
Start Counter
Add 1
Delete 1
Reset
Transcribed Image Text:Value is: 0 Start Counter Add 1 Delete 1 Reset
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY