beingtopper.jkp@gmail.com
+91-8700702530
Free Demo

Being Topper

  • Home
  • About Us
  • Knowledge Base
  • Modules
    • Website Planning and Creation
    • Social Media Marketing Course
    • Search Engine Optimization
    • SEM/PPC Training
  • Branches
    • Ajmer
    • Tilak Nagar
    • Noida
    • Chandigarh
    • Mumbai
  • Contact Us

Being Topper

  • Home
  • About Us
  • Knowledge Base
  • Modules
    • Website Planning and Creation
    • Social Media Marketing Course
    • Search Engine Optimization
    • SEM/PPC Training
  • Branches
    • Ajmer
    • Tilak Nagar
    • Noida
    • Chandigarh
    • Mumbai
  • Contact Us
  • Home
  • About Us
  • Knowledge Base
  • Modules
    • Website Planning and Creation
    • Social Media Marketing Course
    • Search Engine Optimization
    • SEM/PPC Training
  • Branches
    • Ajmer
    • Tilak Nagar
    • Noida
    • Chandigarh
    • Mumbai
  • Contact Us

Being Topper

  • Home
  • About Us
  • Knowledge Base
  • Modules
    • Website Planning and Creation
    • Social Media Marketing Course
    • Search Engine Optimization
    • SEM/PPC Training
  • Branches
    • Ajmer
    • Tilak Nagar
    • Noida
    • Chandigarh
    • Mumbai
  • Contact Us
B.tech notesBCA NOTESEvent HandlingInformation technologyJava Programs

Java program for event Handelling

Being Topper 17/03/2014 0 Comments

Java program for event Handelling

import java.awt.*;
import java.awt.event.*;
class EventTest implements ActionListener
{Frame fr;
Button b1,b2,b3,b4;
TextField tf1,tf2,tf3;
Label lb1,lb2,lb3;

EventTest( )
{ fr = new Frame("myframe" );
fr.setLayout(null);
b1= new Button ("Add") ;
b2= new Button ("Sub") ;
b3= new Button ("Mul") ;
b4= new Button ("Div") ;
tf1 = new TextField() ;
tf2 = new TextField() ;
tf3= new TextField() ;
lb1 = new Label("no1") ;
lb2 = new Label("no2") ;
lb3 = new Label("res") ;
tf1.setBounds( 50,50,100,50) ;
tf2.setBounds( 50,120,100,50) ;
tf3.setBounds( 50,190,100,50) ;
lb1.setBounds(10,50,35,50);
lb2.setBounds(10,120,35,50);
lb3.setBounds(10,190,35,50);
b1.setBounds( 30,260,35,50);
b2.setBounds( 85,260,35,50);
b3.setBounds( 140,260,35,50);
b4.setBounds( 195,260,35,50);
fr.add( tf1) ;
fr.add( tf2) ;
fr.add( tf3) ;
fr.add( lb1) ;
fr.add( lb2) ;
fr.add( lb3) ;
fr.add( b1) ;
fr.add( b2) ;
fr.add( b3) ;
fr.add( b4) ;
b1.addActionListener( this );
b2.addActionListener( this );
b3.addActionListener( this );
b4.addActionListener( this );

fr.setSize(600,700);
fr.setVisible(true);
}
public void actionPerformed (ActionEvent e )
{
if ( e.getSource() == b1 )
{
String str1 = tf1.getText() ;
String str2 = tf2.getText() ;
int s1 = Integer.parseInt(str1) ;
int s2 = Integer.parseInt(str2) ;
int result = (s1+s2) ;
String str3 =" " + result ;
tf3.setText ( str3) ;
}

if ( e.getSource() == b2 )
{
String str1 = tf1.getText() ;
String str2 = tf2.getText() ;
int s1 = Integer.parseInt(str1) ;
int s2 = Integer.parseInt(str2) ;
int result = s1-s2 ;
String str3 =" " + result ;
tf3.setText ( str3) ;
}
if ( e.getSource() == b3 )
{
String str1 = tf1.getText() ;
String str2 = tf2.getText() ;
int s1 = Integer.parseInt(str1) ;
int s2 = Integer.parseInt(str2) ;
int result = s1*s2 ;
String str3 =" " + result ;
tf3.setText ( str3) ;
}

if ( e.getSource() == b4 )
{
String str1 = tf1.getText() ;
String str2 = tf2.getText() ;
int s1 = Integer.parseInt(str1) ;
int s2 = Integer.parseInt(str2) ;
int result = (s1/s2) ;
String str3 =" " + result ;
tf3.setText ( str3) ;
}
}

public static void main (String s[] )
{
new EventTest();
}

}

java programs
700 Views
AboutBeing Topper
In Socials:
PrevJava Program for working Pacman game18/02/2014
java program for counting vowels , consonants , digits and whitespaces ...17/03/2014Next

Related Posts

Algorithm Design and analysis ProgramsB.tech notesBCA NOTESC++ programInformation technology

c++ program to perform naive string matching

WRITE A PROGRAM TO PERFORM NAÏVE STRING MATCHING (more…)

Being Topper 25/05/2013
BCA NOTESVB.Net progrmas

WAP to demonstrate Polymorphism in Vb.net through Method Overloading

 Demonstratation of  Polymorphism in Vb.net through Method Overloading : code begins...

Being Topper 17/10/2014
Categories
Recent Posts
  • Vipin Khutail Organizes International Conference for Digital Excellence 2, Elevating the Future of Technology
  • India’s Top Occult Science Enthusiasts Gather at AgyatOnSearch – Awards & Seminar in New Delhi
  • India’s Leading Digital Marketer, Vipin Khutail Interacted with Top Influencers of Delhi at BJP West Delhi’s Event
  • Vipin Khutail Organized Awards & Honor Ceremony to Celebrate Social Reformers on Doctor’s Day
  • Vipin Khutail organized International Conference on Educational Excellence & Honored Visionaries

Copyright © 2021 Being Topper ® . All Rights Reserved