Preview

Java App

Satisfactory Essays
Open Document
Open Document
278 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Java App
import javax.swing.*; import java.awt.*; import java.awt.event.*;

public class adsubprodquoRadButton extends JFrame implements ActionListener { private JButton answer, clr; private JRadioButton r1,r2,r3,r4; //private JCheckBox c1; private JTextField txt1,txt2; //private JLabel lbl1; public adsubprodquoRadButton() {//CONSTRUCTOR Container p = getContentPane(); JPanel jp = new JPanel(); //JPanel jp1 = new JPanel(); ButtonGroup bg = new ButtonGroup(); //ButtonGroup bg1 = new ButtonGroup(); p.add(jp);

bg.add(r1=new JRadioButton("Mutiplication")); bg.add(r2=new JRadioButton("Addtion")); bg.add(r3=new JRadioButton("Subtraction")); bg.add(r4=new JRadioButton("Division")); //bg1.add(c1= new JCheckBox ("Mushroom")); //jp1.add(c1);

//jp.add(lbl1 = new JLabel ("hello")); jp.add(r1); jp.add(r2); jp.add(r3); jp.add(r4); jp.add(txt1=new JTextField(5)); jp.add(txt2=new JTextField(5)); jp.add(answer=new JButton("Show Answer")); jp.add(clr=new JButton("Clear")); answer.addActionListener(this); clr.addActionListener(this); }//constructor public static void main(String[] args) { adsubprodquoRadButton js = new adsubprodquoRadButton(); js.setVisible(true); js.setSize(400,100); js.setTitle("Basic Aritmetic Operations - *, +, -, /"); js.setResizable(true); } public void actionPerformed(ActionEvent e) { double ans=0.0; JOptionPane j = new JOptionPane(); if(e.getSource() == answer) { if(r1.isSelected()) { ans=Double.parseDouble(txt2.getText()) * Double.parseDouble(txt1.getText()); j.showMessageDialog(null,"Answer: "+ ans); }else if(r2.isSelected()) { ans=Double.parseDouble(txt2.getText()) + Double.parseDouble(txt1.getText()); j.showMessageDialog(null,"Answer: "+ ans); }else if(r3.isSelected()) { ans=Double.parseDouble(txt2.getText()) - Double.parseDouble(txt1.getText());

You May Also Find These Documents Helpful

  • Satisfactory Essays

    a1 script win213

    • 380 Words
    • 2 Pages

    Enter the book title –data type string. If the user enters a null string, the program should beep and redisplay the needed value…

    • 380 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    System.out.println("i = " + i + " f = " + f + " d = " + d);…

    • 2338 Words
    • 10 Pages
    Powerful Essays
  • Good Essays

    PRG/420 Week 3

    • 1025 Words
    • 5 Pages

    /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package commission2; import java.lang. *; import java.text. DecimalFormat; import java.util.…

    • 1025 Words
    • 5 Pages
    Good Essays
  • Satisfactory Essays

    Pt1420 Unit 7 Study Guide

    • 582 Words
    • 3 Pages

    Display it on the next line in decimal and the user if he or she wants to do it. Again if the user type ‘y’ or ‘Y’ the program repeats. If the user type anything else the program terminates. If the user types an illegal character, prompt the user to type again. Page: 115…

    • 582 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Prg421 Week 2 Ia

    • 565 Words
    • 3 Pages

    JOptionPane; import javax.swing. JPanel; import javax.swing. JScrollPane; import javax.swing. JTextArea; import javax.swing. JTextField; import javax.swing.…

    • 565 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Lab 5

    • 463 Words
    • 5 Pages

    // Once the user enters a Q it will break from this method and return to Main().…

    • 463 Words
    • 5 Pages
    Satisfactory Essays
  • Good Essays

    Programing Problems

    • 721 Words
    • 3 Pages

    Input Score1 Display “Please enter score for player 2 game 1” Input Score2 Display “Please enter score for player 1 game 2”…

    • 721 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    problems below and submit your work in an Excel document. Be sure to show all of your work and clearly label all…

    • 263 Words
    • 1 Page
    Satisfactory Essays
  • Powerful Essays

    Bsbm504b Review Report

    • 3822 Words
    • 16 Pages

    Identified at least two possible problems with implementation. (Select 2-3 points and giving in details why you are using them…

    • 3822 Words
    • 16 Pages
    Powerful Essays
  • Good Essays

    Grand Theft Auto Cheats

    • 695 Words
    • 3 Pages

    While playing the game, quickly press B, LB, Y, RT, A, X, B, Right, X, LB(3).…

    • 695 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Jharna Software

    • 896 Words
    • 4 Pages

    Harvard Business Case: "Living on Internet Time: Product Development at Netscape, Yahoo!, NetDyanamics, and Microsoft".…

    • 896 Words
    • 4 Pages
    Good Essays
  • Good Essays

    Java

    • 490 Words
    • 3 Pages

    Write a Java program to demonstrate using bitmaps and bitwise operators to sort and remove duplicates from a file of random phone numbers. Do not confuse the term bitmap used for compressing data into smaller spaces with the bitmap that has come to mean a graphic image.…

    • 490 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    West

    • 425 Words
    • 2 Pages

    package je; import java.applet. Applet; import java.awt. Color; import java.awt. Graphics; public class je { public static void main(String[] args) { // TODO Auto-generated method stub /* <APPLET CODE="Animation. JAVA" WIDTH=400 HEIGHT=300> */ //The basic applet class.…

    • 425 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    CONTENTS CONTROLS................................................................................................................................................... 3 STARTING THE GAME........................................................................................................................ 8 LEARNING THE BASICS................................................................................................................. 10 GAME MODES......................................................................................................................................... 14 ONLINE PLAY..........................................................................................................................................…

    • 6251 Words
    • 33 Pages
    Powerful Essays
  • Good Essays

    /* * 请完善这里的注释 */ package javafxgrouping; /** * * @author 孙平 094632220 */ public class StudentEntity { //从这里开始编写你的代码 private String id; private String name; private String className; public StudentEntity(){ } public StudentEntity(String aID, String aName, String className) { this.id = aID; this.name = aName; this.className =…

    • 1540 Words
    • 7 Pages
    Good Essays

Related Topics