1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kodGreya [7K]
4 years ago
6

Create a GUI application that allows the user to select a rate category (from a set of radio buttons), and enter the number of m

inutes of the call as a decimal into a text field. There should be separate Calculate Charges and Exit buttons implemented as a JPanel. Minutes Panel uses a 1X2 GridLayout. A dialog box should display the charge for the call. Implement LongDistance by extending JFrame and both MinutesPanel and RatePanel as separate classes that extend JPanel.

Computers and Technology
1 answer:
aniked [119]4 years ago
6 0

Answer:

Kindly note that, you're to replace "at" with shift 2 as the brainly text editor can't take the symbol

Explanation:

Below is the Java Swing implementation of the assignment.

=========================== LongDistance.java ====================================

import java.awt.GridLayout;

import javax.swing.*;

public class LongDistance extends JFrame{

 

  /**

  *

  */

  public static float rate;

  public static float minutes;

  public static float total;

 

  LongDistance(){

     

     

      RatePanel rp = new RatePanel();

     

      MinutesPanel mp = new MinutesPanel();

     

      ButtonsPanel bp = new ButtonsPanel();

     

      this.setLayout(new GridLayout(3, 1));

     

 

     

      this.add(rp);

      this.add(mp);

      this.add(bp);

             

      this.setDefaultCloseOperation(EXIT_ON_CLOSE);

      this.setSize(250, 250);

      this.setVisible(true);

  }

 

}

============================ RatePanel.java ==================================

import java.awt.Dimension;

import java.awt.GridLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.BorderFactory;

import javax.swing.ButtonGroup;

import javax.swing.JPanel;

import javax.swing.JRadioButton;

import javax.swing.border.Border;

public class RatePanel extends JPanel implements ActionListener {

  /**

  *

  */

  private JRadioButton jr1, jr2, jr3;

  RatePanel(){

     

      Border panelBorder = BorderFactory.createTitledBorder("Select a Rate Category");

     

     

      jr1 = new JRadioButton("Daytime ($0.7) per minute");

      jr2 = new JRadioButton("Evening ($0.12) per minute");

      jr3 = new JRadioButton("Off-Peak ($0.05) per minute");

      ButtonGroup bg = new ButtonGroup();

     

      this.setLayout(new GridLayout(3,1));

      this.setBorder(panelBorder);

      this.setPreferredSize(new Dimension(800, 150));

     

      this.add(jr1);

      this.add(jr2);

      this.add(jr3);

     

      bg.add(jr1);

      bg.add(jr2);

      bg.add(jr3);

     

      jr1.addActionListener(this);

      jr2.addActionListener(this);

      jr3.addActionListener(this);

         

  }

  "at"Override

  public void actionPerformed(ActionEvent arg0) {

      // TODO Auto-generated method stub

     

      if(arg0.getSource() == jr1){

          LongDistance.rate = 0.07f;

      }

     

      if(arg0.getSource() == jr2){

          LongDistance.rate = 0.12f;

      }

     

      if(arg0.getSource() == jr3){

          LongDistance.rate = 0.05f;

      }

     

  }

}

=============================== MinutesPanel.java =============================

import java.awt.Dimension;

import java.awt.GridLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.KeyEvent;

import java.awt.event.KeyListener;

import javax.swing.*;

import javax.swing.border.Border;

import javax.swing.event.DocumentListener;

public class MinutesPanel extends JPanel implements KeyListener{

  JTextField jt;

 

  MinutesPanel(){

      Border panelBorder = BorderFactory.createTitledBorder("Time Of Call");

     

      this.setLayout(new GridLayout(1, 2));

     

      JLabel jl = new JLabel("Minutes: ");

      jt = new JTextField();

     

jt.setBounds(50,50,150,20);

      this.setPreferredSize(new Dimension(10, 10));

      this.setBorder(panelBorder);

      this.add(jl);

      this.add(jt);

     

      jt.addKeyListener(this);

 

     

     

     

  }

  "at"Override

  public void keyPressed(KeyEvent arg0) {

      // TODO Auto-generated method stub

     

  }

  "at"Override

  public void keyReleased(KeyEvent arg0) {

      // TODO Auto-generated method stub

      if(jt.getText() != "")

          LongDistance.minutes = Float.parseFloat(jt.getText());

  }

  "at"Override

  public void keyTyped(KeyEvent arg0) {

      // TODO Auto-generated method stub

     

     

  }

 

}

============================= ButtonsPanel.java ============================

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.JButton;

import javax.swing.JOptionPane;

import javax.swing.JPanel;

public class ButtonsPanel extends JPanel implements ActionListener{

  JButton calculate;

  JButton exit;

  ButtonsPanel(){

      calculate = new JButton("Calculate Charges");

      exit = new JButton("Exit");

     

      this.add(calculate);

      this.add(exit);

     

      calculate.addActionListener(this);

      exit.addActionListener(this);

     

  }

  "at"Override

  public void actionPerformed(ActionEvent arg0) {

      // TODO Auto-generated method stub

     

      if(arg0.getSource() == calculate){

                     

          System.out.println("r " + LongDistance.rate);

          System.out.println("m " + LongDistance.minutes);

         

          LongDistance.total = LongDistance.rate * LongDistance.minutes;

          JOptionPane.showMessageDialog(null, "Total Charges: " +LongDistance.total);

         

      }

     

      if(arg0.getSource() == exit){

          System.exit(0);

      }

  }

}

============================ App.java==============================

public class App {

  public static void main(String[] args) {

     

      LongDistance ld = new LongDistance();

     

  }

}

Check the output below

You might be interested in
Although the American National Standards Institute publishes the specifications for a standard SQL language, each DBMS vendor ha
Levart [38]

Answer: Dialect a variant

Explanation:

The dialect a variant of the structured query language (SQL) is basically refers to the database which basically define the different types of features of SQL language which can be easily be access from the given database in the system.

  • The term dialect means that the variant of the given languages and we can easily characterized by the various types of the given standard languages.  
  • The dialect is basically refers to the linguistic structure features in the structured query language.

According to the given question, the American national standard institute published the different types of SQL language specification and each database management system vendors has dialect of variant in the system.  

Therefore, Dialect a variant is the correct answer.

8 0
3 years ago
In an airline reservation system, on entering the flight number, the flight schedule and the flight status are displayed. In thi
Svet_ta [14]

Answer:

b. what-is

Explanation:

According to my research on the decision making analysis, I can say that based on the information provided within the question this analysis is called "what-is". This (like described in the question) is the act of providing a specific piece of information in order to receive a set of information in regards to what you provided.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

5 0
3 years ago
Read 2 more answers
Based on your understanding of Moore’s Law, what do you predict will be the next trend in the evolution of computers?
miss Akunina [59]

Actually, the answer is (B) Computers will continue to become smaller in size and become faster.  For example, google  i9-9900k mini itx pc build. You can have an insanely powerful pc and it be very small.

5 0
3 years ago
Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binar
MAXImum [283]

Answer:

thats what i was about to ask. im not sure

Explanation:

sorry   '-'

3 0
3 years ago
Give the value of the zero flag, the carry flag, the signflag, and the overflow flag after each of the following instructions if
Vanyuwa [196]
The correct answer is A for this question
6 0
2 years ago
Other questions:
  • To insert a field between existing fields, right-click the column heading for the field that will follow the new field, and then
    11·1 answer
  • Writing a program in a language such as c or java is known as _____ the program.
    10·1 answer
  • Which table option enables you to combine the contents of several cells into one cell?
    9·2 answers
  • What is the definition of delimited text?
    14·2 answers
  • A technician has just finished installing a secondary OS on a workstation. After rebooting the computer, the technician receives
    13·1 answer
  • Which of the following is an example of fine art? 1. fashion 2. interior design 3. painting 4. product design
    7·2 answers
  • Why wouldn't a game using just run-length encodings be challenging?
    9·1 answer
  • Trade Periodicals are usually highly scholarly resources<br> True<br><br> False
    5·1 answer
  • What might be some challenges if you’re trying to design a product for someone
    14·2 answers
  • Explain in detail what it means to synchronize computers and mobile devices and include at least two strategies for keeping your
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!