import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Ass140 extends JFrame implements ActionListener
{
JLabel l1,l2,l3;
JButton b1;
JTextField t1,t2,t3;
Ass140()
{
l1=new JLabel("INPUT 1");
l2=new JLabel("INPUT 2");
l3=new JLabel("OUTPUT");
b1=new JButton("BUTTON 1");
t1=new JTextField(10);
t2=new JTextField(10);
t3=new JTextField(10);
add(l1);
add(t1);
add(l2);
add(t2);
add(l3);
add(t3);
add(b1);
b1.addActionListener(this);
setSize(200,200);
setLayout(new FlowLayout());
setTitle("Assignment 139");
}
public void actionPerformed(ActionEvent ae)
{
float a,b,c;
if(ae.getSource()==b1)
{
a=Float.parseFloat(t1.getText());
b=Float.parseFloat(t2.getText());
c=a+b;
t3.setText(String.valueOf(c));
}
}
public static void main(String args[])
{
Ass140 a=new Ass140();
a.setVisible(true);
a.setLocation(200,200);
}
}
Thank you so much for posting this example
ReplyDeleteThank you so much for posting this example
ReplyDeleteThanks
ReplyDeleteThanks.. It is very useful.
ReplyDeletewrite a program takes two numbers from the user and display their addition using GUI
ReplyDeletei need the answer of this question right now
Nice Blog Sir...
ReplyDeleterelated POst :- how to easily start programming in java??
https://coding-worm.blogspot.in/2017/08/v-behaviorurldefaultvmlo.html
This comment has been removed by the author.
ReplyDeletehow to add exit button and exit???
ReplyDeleteReally great post, I simply unearthed your site and needed to say that I have truly appreciated perusing your blog entries.
ReplyDeletepython Training institute in Pune
python Training institute in Chennai
python Training institute in Bangalore
I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post.is article.
ReplyDeleteData Science course in Chennai
Data science course in bangalore
Data science course in pune
Data science online course
Data Science Interview questions and answers
Data Science Tutorial
Data science course in bangalore
Very reliable to we the beginners of the programmer. Easy to understand Sir.
ReplyDeleteKeep posting new programs Sir
I am highly overwhelmed to read this perfect piece of writing. It has really enthused me to read more on this topic.
ReplyDeleteData Science training in Mumbai
Data Science course in Mumbai
SAP training in Mumbai
I feel a lot more people need to read this, very good info! .
ReplyDeletedata scientist training and placement
Informative blog
ReplyDeletebusiness analytics course in ahmedabad
They're produced by the very best degree developers who will be distinguished for your polo dress creation. You'll find Ron Lauren inside an exclusive array which includes particular classes for men, women.
ReplyDeletedata analytics courses in hyderabad