Can you create this quick GUI? The Calculator class must instantiate the CalculatorFrame class and the CalculatorFrame class must be where the calculator gets "built". I run the Calculator class, so it must have a main method. The CalculatorFrame doesnt have a main. uses jframe. Java. Two classes. EXAMPLE EXAMPLE on how to separate into two classes:   // LabelFrame.java // JLabels with text and icons. import java.awt.FlowLayout; // specifies how components are arranged import javax.swing.JFrame; // provides basic window features import javax.swing.JLabel; // displays text and images import javax.swing.SwingConstants; // common constants used with Swing import javax.swing.Icon; // interface used to manipulate images import javax.swing.ImageIcon; // loads images public class LabelFrame extends JFrame  {    private final JLabel label1; // JLabel with just text    private final JLabel label2; // JLabel constructed with text and icon    private final JLabel label3; // JLabel with added text and icon    // LabelFrame constructor adds JLabels to JFrame    public LabelFrame()    {       super("Testing JLabel");       setLayout(new FlowLayout()); // set frame layout       // JLabel constructor with a string argument       label1 = new JLabel("Label with text");       label1.setToolTipText("This is label1");       add(label1); // add label1 to JFrame       // JLabel constructor with string, Icon and alignment arguments       Icon bug = new ImageIcon(getClass().getResource("bug1.png"));       label2 = new JLabel("Label with text and icon", bug,           SwingConstants.LEFT);       label2.setToolTipText("This is label2");       add(label2); // add label2 to JFrame       label3 = new JLabel(); // JLabel constructor no arguments       label3.setText("Label with icon and text at bottom");       label3.setIcon(bug); // add icon to JLabel       label3.setHorizontalTextPosition(SwingConstants.CENTER);       label3.setVerticalTextPosition(SwingConstants.BOTTOM);       label3.setToolTipText("This is label3");       add(label3); // add label3 to JFrame    }  } // end class LabelFrame ----------------------------------------------------------------------------------------------------------------------------------------------------- //LabelTest.java // Testing LabelFrame. import javax.swing.JFrame; public class LabelTest  {    public static void main(String[] args)    {        LabelFrame labelFrame = new LabelFrame();        labelFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);       labelFrame.setSize(260, 180);        labelFrame.setVisible(true);     }  } // end class LabelTest

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Can you create this quick GUI? The Calculator class must instantiate the CalculatorFrame class and the CalculatorFrame class must be where the calculator gets "built". I run the Calculator class, so it must have a main method. The CalculatorFrame doesnt have a main.

uses jframe. Java. Two classes.

EXAMPLE EXAMPLE on how to separate into two classes:

 

// LabelFrame.java
// JLabels with text and icons.
import java.awt.FlowLayout; // specifies how components are arranged
import javax.swing.JFrame; // provides basic window features
import javax.swing.JLabel; // displays text and images
import javax.swing.SwingConstants; // common constants used with Swing
import javax.swing.Icon; // interface used to manipulate images
import javax.swing.ImageIcon; // loads images

public class LabelFrame extends JFrame 
{
   private final JLabel label1; // JLabel with just text
   private final JLabel label2; // JLabel constructed with text and icon
   private final JLabel label3; // JLabel with added text and icon

   // LabelFrame constructor adds JLabels to JFrame
   public LabelFrame()
   {
      super("Testing JLabel");
      setLayout(new FlowLayout()); // set frame layout

      // JLabel constructor with a string argument
      label1 = new JLabel("Label with text");
      label1.setToolTipText("This is label1");
      add(label1); // add label1 to JFrame

      // JLabel constructor with string, Icon and alignment arguments
      Icon bug = new ImageIcon(getClass().getResource("bug1.png"));
      label2 = new JLabel("Label with text and icon", bug, 
         SwingConstants.LEFT);
      label2.setToolTipText("This is label2");
      add(label2); // add label2 to JFrame

      label3 = new JLabel(); // JLabel constructor no arguments
      label3.setText("Label with icon and text at bottom");
      label3.setIcon(bug); // add icon to JLabel
      label3.setHorizontalTextPosition(SwingConstants.CENTER);
      label3.setVerticalTextPosition(SwingConstants.BOTTOM);
      label3.setToolTipText("This is label3");
      add(label3); // add label3 to JFrame
   } 
} // end class LabelFrame

-----------------------------------------------------------------------------------------------------------------------------------------------------

//LabelTest.java
// Testing LabelFrame.
import javax.swing.JFrame;

public class LabelTest 
{
   public static void main(String[] args)
   { 
      LabelFrame labelFrame = new LabelFrame(); 
      labelFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      labelFrame.setSize(260, 180); 
      labelFrame.setVisible(true); 
   } 
} // end class LabelTest

The image displays a simple calculator interface commonly found on computer operating systems. The calculator window includes:

- A title bar at the top with the label "Calculator" and buttons to minimize, maximize, or close the window.
- A display screen area for showing input and results, currently empty.
- Below the display screen is a numeric keypad with the numbers 0-9.
- Arithmetic operation buttons are also present: division (/), multiplication (*), subtraction (-), addition (+).
- An equal sign (=) button for calculating results.
- A decimal point (.) button for working with decimal numbers.

This type of calculator is used for basic arithmetic operations.
Transcribed Image Text:The image displays a simple calculator interface commonly found on computer operating systems. The calculator window includes: - A title bar at the top with the label "Calculator" and buttons to minimize, maximize, or close the window. - A display screen area for showing input and results, currently empty. - Below the display screen is a numeric keypad with the numbers 0-9. - Arithmetic operation buttons are also present: division (/), multiplication (*), subtraction (-), addition (+). - An equal sign (=) button for calculating results. - A decimal point (.) button for working with decimal numbers. This type of calculator is used for basic arithmetic operations.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Random Class and its operations
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education