Question: PROVIDED CODE : import javax.swing.*; import java.awt.*; import java.awt.event.*; public class GUI implements ActionListener { private JLabel l1,l2; private JFrame f1; private JPanel p1,p2,p3; private

 PROVIDED CODE : import javax.swing.*; import java.awt.*; import java.awt.event.*; public classGUI implements ActionListener { private JLabel l1,l2; private JFrame f1; private JPanel

PROVIDED CODE :

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class GUI implements ActionListener

{

private JLabel l1,l2;

private JFrame f1;

private JPanel p1,p2,p3;

private JTextField t1,t2;

private JMenuBar b1;

private JMenu m1,m2;

private JMenuItem i1,i2,i3,i4;

private int c=0;

public GUI()

{

make();

}

public void make(){

f1=new JFrame("counter");

f1.setSize(400,200);

l1=new JLabel("A : ");

l2=new JLabel("b : ");

t1=new JTextField("0.0");

t2=new JTextField("0.0");

b1=new JMenuBar();

m1=new JMenu("+#-");

m2=new JMenu("*#-");

i1=new JMenuItem("+");

i2=new JMenuItem("-");

i3=new JMenuItem("*");

i4=new JMenuItem("/");

p1=new JPanel();

p2=new JPanel();

p3=new JPanel();

i1.addActionListener(this);

i2.addActionListener(this);

i3.addActionListener(this);

i4.addActionListener(this);

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

m1.add(i1);

m1.add(i2);

m2.add(i3);

m2.add(i4);

b1.add(m1);

b1.add(m2);

p1.add(b1);

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

p2.add(l1);

p2.add(t1);

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

p3.add(l2);

p3.add(t2);

p1.add(p2);

p1.add(p3);

f1.getContentPane().add(p1);

f1.setVisible(true);

}

public void actionPerformed(ActionEvent m){

if(m.getSource()==i1){

String x1=t1.getText();

String x2=t2.getText();

double a= Double.parseDouble(x1);

double b= Double.parseDouble(x2);

double c=a+b;

String r=String.valueOf(c);

JOptionPane.showMessageDialog(f1,r);

}

if(m.getSource()==i2){

String x1=t1.getText();

String x2=t2.getText();

double a= Double.parseDouble(x1);

double b= Double.parseDouble(x2);

double c=a-b;

String r=String.valueOf(c);

JOptionPane.showMessageDialog(f1,r);

}

if(m.getSource()==i3){

String x1=t1.getText();

String x2=t2.getText();

double a= Double.parseDouble(x1);

double b= Double.parseDouble(x2);

double c=a*b;

String r=String.valueOf(c);

JOptionPane.showMessageDialog(f1,r);

}

if(m.getSource()==i4){

String x1=t1.getText();

String x2=t2.getText();

double a= Double.parseDouble(x1);

double b= Double.parseDouble(x2);

double c=a/b;

String r=String.valueOf(c);

JOptionPane.showMessageDialog(f1,r);

}

}

}

3:107 cs212-lab11 CS 212 Object-Oriented Programming Lab Assignment 10 In this Lab Assignment you will implement a sample application using the elements discussed in the lecture: JButton JLabel JTextField JMenuBar JMenuItem JMenu . and a message dialog. The user interface looks and behaves in the following way: Lab Assignment 11 JLabel th JTextField Dagings JButton The application has six String values: o three constants that save the initial values of the first name, the name and the country. o three strings that save the values of the first name, the name and the country. The text in the JTextField fields can be modified. After pushing the save button the text of the JTextField fields is read and saved in the three strings. After pushing the cancel button, the text in the JTextField fields is replaced by the values in the saved strings. (not the initial values!) After pushing the printbutton the text in the JTextField fields is saved to the strings and printed on the Terminal window of Blue) (System.out.println(). The menu item Data has a sub menu: Etah Assignment 11 Data About Sential Data Bilbo Delete Data Bagain Shine With Set Initial Data the initial string values of first name, name and country are copied to the strings and displayed. With Delete Data the three strings are set to null, 3:10 ..11 cs212-lab11 .and a message dialog. The user interface looks and behaves in the following way: JLabel Lab Assignment 11 Data About tha: Baggings Shire Honcept JTextField JButton The application has six String values: o three constants that save the initial values of the first name, the name and the country, o three strings that save the values of the first name, the name and the country. The text in the JTextField fields can be modified. After pushing the save button the text of the JTextField fields is read and saved in the three strings. After pushing the cancel button, the text in the JTextField fields is replaced by the values in the saved strings. (not the initial values!) After pushing the printbutton the text in the JTextField fields is saved to the strings and printed on the Terminal window of Blue) (System.out.println(). The menu item Data has a sub menu: Lab Assignment 11 Data About Set initial Duta Buto Delete Data Bagain With Set Initial Data the initial string values of first name, name and country are copied to the strings and displayed. With Delete Data the three strings are set to null. With About the following message box is displayed (write your own text): Message This is Lab Assignment 11. This sample solution has been programmed by christina class OK CS 212 German Jordanian University Page 1 of 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!