SlideShare a Scribd company logo
Java Swings
• A graphical user interface (GUI) presents a user-
friendly mechanism for interacting with an
application. These are sometimes called controls
or widgets—short for window gadgets. A GUI
component is an object with which the user
interacts via the mouse, the keyboard or another
form of input, such as voice recognition.
• Java’s so-called Swing GUI components from the
javax.swing package. We cover other
Simple GUI-Based Input/Output with
JOptionPane
• Most applications you use on a daily basis use windows or
dialog boxes (also called dialogs) to interact with the user.
For example, an e-mail program allows you to type and
read messages in a window the program provides. Dialog
boxes are windows in which programs display important
messages to the user or obtain information from the user.
Java’s JOptionPane class (package javax.swing) provides
prebuilt dialog boxes for both input and output. These are
displayed by invoking static JOptionPane methods. Program
presents a simple addition application that uses two input
dialogs to obtain integers from the user and a message
dialog to display the sum of the integers the user enters.
• // Addition.java
• // Addition program that uses JOptionPane for input and output.
• import javax.swing.JOptionPane; // program uses JOptionPane
• public class Addition
• {
• public static void main( String[] args )
• {
• // obtain user input from JOptionPane input dialogs
• String firstNumber =
• JOptionPane.showInputDialog( "Enter first integer" );
• String secondNumber =
• JOptionPane.showInputDialog( "Enter second integer" );
• private void
jButton1ActionPerformed(java.awt.event.Acti
onEvent evt) {
• JOptionPane.showMessageDialog(null, "Thank
you");// TODO add your handling code here:
• }
Overview of Swing Components
Non-AWT Upgraded Components
• In addition to offering replacements for all the
basic AWT components, the Swing component
• set includes twice as many new components.
• package hello;
• import javax.swing.*;
• class jpswrd
• {
• public void Testing()
• {
• JPasswordField pwd = new JPasswordField(10);
• int action = JOptionPane.showConfirmDialog(null, pwd,"Enter
Password",JOptionPane.OK_CANCEL_OPTION);
• if(action < 0)JOptionPane.showMessageDialog(null,"Cancel, X or escape key selected");
• else JOptionPane.showMessageDialog(null,"Your password is "+new
String(pwd.getPassword()));
• System.exit(0);
• }
• public static void main(String args[])
• {jpswrd p= new jpswrd();
• p.Testing();}
• }
output
• setEchoChar('+');
• Set character for password field.
JFrame
• A Frame is a top-level window with a title and
a border.
• Frame that adds support for the Swing
component architecture.
JFrame Features
 It’s a window with title, border, (optional)
menu bar and user-specified components.
.It can be moved, resized, iconified.
.It is not a subclass of JComponent.
.Delegates responsibility of managing user-
specified components to a content pane, an
instance of JPanel.
Centering JFrame’s
• By default, a Jframe is displayed in the upper-
left corner of the screen. To display a frame
at a specified location, you can use the
setLocation(x, y) method in the JFrame class.
This method places the upper-left corner of a
frame at location (x, y).
Class constructors
• JFrame()
Constructs a new frame that is initially
invisible.
• JFrame(String title)
Creates a new, initially invisible Frame with
the specified title.
JButton
• A button is a component the user clicks to
trigger a specific action. A Java application
can use several types of buttons, including
command buttons, checkboxes, toggle
buttons and radio buttons.
• all the button types are subclasses of
AbstractButton (package javax.swing), which
declares the common features of Swing
buttons.
Buttons That Maintain State
• The Swing GUI components contain three
types of state buttons—JToggleButton,
• JCheckBox and JRadioButton—that have
on/off or true/false values. Classes
JCheckBox and JRadioButton are subclasses
of JToggleButton
JLabel
• A JLabel displays read-only text, an image, or
both text and an image.
JFileChooser
Allows the the user to choose a file
• import javax.swing.JFileChooser;
• public class swing_examples {
• public static void main(String args[])
• {
• JFileChooser fc = new JFileChooser();
• int returnVal = fc.showOpenDialog(null);
• if(returnVal == JFileChooser.APPROVE_OPTION)
• System.out.println("File: " + fc.getSelectedFile());
• }
• }
JCheckBox Class
• The class JCheckBox is an implementation of a
check box - an item that can be selected or
deselected, and which displays its state to the
user.
Class constructors
of JcheckBox
output
/*code for checkbox that display bold text*/
• font=new Font("",Font.BOLD,14);
• jTextField1.setFont(font);
• /*code for checkbox that display italic text*/
• font=new Font("",Font.ITALIC,14);
• jTextField1.setFont(font);
JRadio Button
• The class JRadioButton is an implementation
of a radio button - an item that can be
selected or deselected, and which displays its
state to the user.
Mathematical Operations using Radio
Buttons
• private void
jButton1ActionPerformed(java.awt.event.Acti
onEvent evt) {
• jTextField1.setText("");
• jTextField2.setText("");
• jTextField3.setText("");
Addition RadioButton
• private void
jRadioButton1ActionPerformed(java.awt.event.A
ctionEvent evt) {
• int num1,num2,result;
• num1=Integer.parseInt(jTextField1.getText());
• num2=Integer.parseInt(jTextField2.getText());
• result=num1+num2;
• jTextField3.setText(String.valueOf(result));
Multiplication RadioButton
• private void
jRadioButton2ActionPerformed(java.awt.event.A
ctionEvent evt) {
• int num1,num2,result;
• num1=Integer.parseInt(jTextField1.getText());
• num2=Integer.parseInt(jTextField2.getText());
• result=num1*num2;
• jTextField3.setText(String.valueOf(result)); //
TODO add your handling code here:
• }
Subtraction RadioButton
• private void
jRadioButton3ActionPerformed(java.awt.event.A
ctionEvent evt) {
• int num1,num2,result;
• num1=Integer.parseInt(jTextField1.getText());
• num2=Integer.parseInt(jTextField2.getText());
• result=num1-num2;
• jTextField3.setText(String.valueOf(result)); //
TODO add your handling code here:
• }
Complete java swing
Complete java swing
Complete java swing

More Related Content

What's hot

Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
PRN USM
 

What's hot (20)

Java- GUI- Mazenet solution
Java- GUI- Mazenet solutionJava- GUI- Mazenet solution
Java- GUI- Mazenet solution
 
java swing
java swingjava swing
java swing
 
Awt and swing in java
Awt and swing in javaAwt and swing in java
Awt and swing in java
 
Java Swing JFC
Java Swing JFCJava Swing JFC
Java Swing JFC
 
The AWT and Swing
The AWT and SwingThe AWT and Swing
The AWT and Swing
 
Java swing
Java swingJava swing
Java swing
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
 
GUI components in Java
GUI components in JavaGUI components in Java
GUI components in Java
 
tL19 awt
tL19 awttL19 awt
tL19 awt
 
java2 swing
java2 swingjava2 swing
java2 swing
 
Java swing
Java swingJava swing
Java swing
 
Java swing
Java swingJava swing
Java swing
 
Gui
GuiGui
Gui
 
Java awt tutorial javatpoint
Java awt tutorial   javatpointJava awt tutorial   javatpoint
Java awt tutorial javatpoint
 
Swings
SwingsSwings
Swings
 
Java Swing
Java SwingJava Swing
Java Swing
 
swingbasics
swingbasicsswingbasics
swingbasics
 
AWT Packages , Containers and Components
AWT Packages , Containers and ComponentsAWT Packages , Containers and Components
AWT Packages , Containers and Components
 
28 awt
28 awt28 awt
28 awt
 
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Java
 

Viewers also liked

Introdução ao Java Swing (Interface)
Introdução ao Java Swing (Interface)Introdução ao Java Swing (Interface)
Introdução ao Java Swing (Interface)
Sérgio Souza Costa
 
Java interface gráfica swing
Java   interface gráfica swingJava   interface gráfica swing
Java interface gráfica swing
Armando Daniel
 
MM PsychoTools Presentation
MM PsychoTools PresentationMM PsychoTools Presentation
MM PsychoTools Presentation
kenneth mashele
 

Viewers also liked (18)

Clases de java swing
Clases de java swingClases de java swing
Clases de java swing
 
Interfaces en Java
Interfaces en JavaInterfaces en Java
Interfaces en Java
 
Chapter 14
Chapter 14Chapter 14
Chapter 14
 
Java swing
Java swingJava swing
Java swing
 
Sdi & mdi
Sdi & mdiSdi & mdi
Sdi & mdi
 
Introdução ao Java Swing (Interface)
Introdução ao Java Swing (Interface)Introdução ao Java Swing (Interface)
Introdução ao Java Swing (Interface)
 
Java interface gráfica swing
Java   interface gráfica swingJava   interface gráfica swing
Java interface gráfica swing
 
java swing tutorial for beginners(java programming tutorials)
java swing tutorial for beginners(java programming tutorials)java swing tutorial for beginners(java programming tutorials)
java swing tutorial for beginners(java programming tutorials)
 
java swing
java swingjava swing
java swing
 
SWISS BULLION
SWISS BULLIONSWISS BULLION
SWISS BULLION
 
Lki sistem perencanaan baru 2015
Lki sistem  perencanaan baru 2015Lki sistem  perencanaan baru 2015
Lki sistem perencanaan baru 2015
 
Navegadores de internet
Navegadores de internetNavegadores de internet
Navegadores de internet
 
MM PsychoTools Presentation
MM PsychoTools PresentationMM PsychoTools Presentation
MM PsychoTools Presentation
 
Nahha Annual report2015
Nahha Annual report2015Nahha Annual report2015
Nahha Annual report2015
 
Francis sewe onyango
Francis sewe onyangoFrancis sewe onyango
Francis sewe onyango
 
SWISS BULLION
SWISS BULLIONSWISS BULLION
SWISS BULLION
 
Updated Tables as of Aug.22, 2015
Updated Tables as of Aug.22, 2015Updated Tables as of Aug.22, 2015
Updated Tables as of Aug.22, 2015
 
Abortion
AbortionAbortion
Abortion
 

Similar to Complete java swing

Chap 1 - Introduction GUI.pptx
Chap 1 - Introduction GUI.pptxChap 1 - Introduction GUI.pptx
Chap 1 - Introduction GUI.pptx
TadeseBeyene
 
Chapter 5 GUI for introduction of java and gui .ppt
Chapter 5 GUI  for  introduction of java and gui .pptChapter 5 GUI  for  introduction of java and gui .ppt
Chapter 5 GUI for introduction of java and gui .ppt
HabibMuhammed2
 
Z blue introduction to gui (39023299)
Z blue   introduction to gui (39023299)Z blue   introduction to gui (39023299)
Z blue introduction to gui (39023299)
Narayana Swamy
 
The java swing_tutorial
The java swing_tutorialThe java swing_tutorial
The java swing_tutorial
sumitjoshi01
 

Similar to Complete java swing (20)

Swing basics
Swing basicsSwing basics
Swing basics
 
Chap 1 - Introduction GUI.pptx
Chap 1 - Introduction GUI.pptxChap 1 - Introduction GUI.pptx
Chap 1 - Introduction GUI.pptx
 
Java Swing Handson Session (1).ppt
Java Swing Handson Session (1).pptJava Swing Handson Session (1).ppt
Java Swing Handson Session (1).ppt
 
Chapter iv(modern gui)
Chapter iv(modern gui)Chapter iv(modern gui)
Chapter iv(modern gui)
 
Java OOP Programming language (Part 7) - Swing
Java OOP Programming language (Part 7) - SwingJava OOP Programming language (Part 7) - Swing
Java OOP Programming language (Part 7) - Swing
 
03_GUI.ppt
03_GUI.ppt03_GUI.ppt
03_GUI.ppt
 
GUI (graphical user interface)
GUI (graphical user interface)GUI (graphical user interface)
GUI (graphical user interface)
 
13457272.ppt
13457272.ppt13457272.ppt
13457272.ppt
 
Chapter 5 GUI for introduction of java and gui .ppt
Chapter 5 GUI  for  introduction of java and gui .pptChapter 5 GUI  for  introduction of java and gui .ppt
Chapter 5 GUI for introduction of java and gui .ppt
 
11basic Swing
11basic Swing11basic Swing
11basic Swing
 
Logic and Coding of Java Interfaces & Swing Applications
Logic and Coding of Java Interfaces & Swing ApplicationsLogic and Coding of Java Interfaces & Swing Applications
Logic and Coding of Java Interfaces & Swing Applications
 
SWING USING JAVA WITH VARIOUS COMPONENTS
SWING USING  JAVA WITH VARIOUS COMPONENTSSWING USING  JAVA WITH VARIOUS COMPONENTS
SWING USING JAVA WITH VARIOUS COMPONENTS
 
Basic swing
Basic swingBasic swing
Basic swing
 
Z blue introduction to gui (39023299)
Z blue   introduction to gui (39023299)Z blue   introduction to gui (39023299)
Z blue introduction to gui (39023299)
 
Graphical User Interface (Gui)
Graphical User Interface (Gui)Graphical User Interface (Gui)
Graphical User Interface (Gui)
 
14a-gui.ppt
14a-gui.ppt14a-gui.ppt
14a-gui.ppt
 
object oriented programming examples
object oriented programming examplesobject oriented programming examples
object oriented programming examples
 
The java swing_tutorial
The java swing_tutorialThe java swing_tutorial
The java swing_tutorial
 
The java rogramming swing _tutorial for beinners(java programming language)
The java rogramming swing _tutorial for beinners(java programming language)The java rogramming swing _tutorial for beinners(java programming language)
The java rogramming swing _tutorial for beinners(java programming language)
 
swings.pptx
swings.pptxswings.pptx
swings.pptx
 

More from jehan1987

More from jehan1987 (7)

Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)
 
Artifitial intelligence (ai) all in one
Artifitial intelligence (ai) all in oneArtifitial intelligence (ai) all in one
Artifitial intelligence (ai) all in one
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
Java Thread & Multithreading
Java Thread & MultithreadingJava Thread & Multithreading
Java Thread & Multithreading
 
Object oriented programming in C++
Object oriented programming in C++Object oriented programming in C++
Object oriented programming in C++
 
Data structure and algorithm All in One
Data structure and algorithm All in OneData structure and algorithm All in One
Data structure and algorithm All in One
 
Assessment of project management practices in pakistani software industry
Assessment of project management practices in pakistani software industryAssessment of project management practices in pakistani software industry
Assessment of project management practices in pakistani software industry
 

Recently uploaded

Online blood donation management system project.pdf
Online blood donation management system project.pdfOnline blood donation management system project.pdf
Online blood donation management system project.pdf
Kamal Acharya
 
Hall booking system project report .pdf
Hall booking system project report  .pdfHall booking system project report  .pdf
Hall booking system project report .pdf
Kamal Acharya
 

Recently uploaded (20)

HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and ClusteringKIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
 
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical EngineeringIntroduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
 
Explosives Industry manufacturing process.pdf
Explosives Industry manufacturing process.pdfExplosives Industry manufacturing process.pdf
Explosives Industry manufacturing process.pdf
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Construction method of steel structure space frame .pptx
Construction method of steel structure space frame .pptxConstruction method of steel structure space frame .pptx
Construction method of steel structure space frame .pptx
 
Furniture showroom management system project.pdf
Furniture showroom management system project.pdfFurniture showroom management system project.pdf
Furniture showroom management system project.pdf
 
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptxCloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
 
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdfRESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
 
Online blood donation management system project.pdf
Online blood donation management system project.pdfOnline blood donation management system project.pdf
Online blood donation management system project.pdf
 
Scaling in conventional MOSFET for constant electric field and constant voltage
Scaling in conventional MOSFET for constant electric field and constant voltageScaling in conventional MOSFET for constant electric field and constant voltage
Scaling in conventional MOSFET for constant electric field and constant voltage
 
İTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopİTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering Workshop
 
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWINGBRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
IT-601 Lecture Notes-UNIT-2.pdf Data Analysis
IT-601 Lecture Notes-UNIT-2.pdf Data AnalysisIT-601 Lecture Notes-UNIT-2.pdf Data Analysis
IT-601 Lecture Notes-UNIT-2.pdf Data Analysis
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
Hall booking system project report .pdf
Hall booking system project report  .pdfHall booking system project report  .pdf
Hall booking system project report .pdf
 
Pharmacy management system project report..pdf
Pharmacy management system project report..pdfPharmacy management system project report..pdf
Pharmacy management system project report..pdf
 
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data StreamKIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
 

Complete java swing

  • 2. • A graphical user interface (GUI) presents a user- friendly mechanism for interacting with an application. These are sometimes called controls or widgets—short for window gadgets. A GUI component is an object with which the user interacts via the mouse, the keyboard or another form of input, such as voice recognition. • Java’s so-called Swing GUI components from the javax.swing package. We cover other
  • 3.
  • 4.
  • 5.
  • 6. Simple GUI-Based Input/Output with JOptionPane • Most applications you use on a daily basis use windows or dialog boxes (also called dialogs) to interact with the user. For example, an e-mail program allows you to type and read messages in a window the program provides. Dialog boxes are windows in which programs display important messages to the user or obtain information from the user. Java’s JOptionPane class (package javax.swing) provides prebuilt dialog boxes for both input and output. These are displayed by invoking static JOptionPane methods. Program presents a simple addition application that uses two input dialogs to obtain integers from the user and a message dialog to display the sum of the integers the user enters.
  • 7. • // Addition.java • // Addition program that uses JOptionPane for input and output. • import javax.swing.JOptionPane; // program uses JOptionPane • public class Addition • { • public static void main( String[] args ) • { • // obtain user input from JOptionPane input dialogs • String firstNumber = • JOptionPane.showInputDialog( "Enter first integer" ); • String secondNumber = • JOptionPane.showInputDialog( "Enter second integer" );
  • 8.
  • 9.
  • 10. • private void jButton1ActionPerformed(java.awt.event.Acti onEvent evt) { • JOptionPane.showMessageDialog(null, "Thank you");// TODO add your handling code here: • }
  • 11. Overview of Swing Components
  • 12.
  • 13.
  • 14.
  • 15.
  • 16. Non-AWT Upgraded Components • In addition to offering replacements for all the basic AWT components, the Swing component • set includes twice as many new components.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22. • package hello; • import javax.swing.*; • class jpswrd • { • public void Testing() • { • JPasswordField pwd = new JPasswordField(10); • int action = JOptionPane.showConfirmDialog(null, pwd,"Enter Password",JOptionPane.OK_CANCEL_OPTION); • if(action < 0)JOptionPane.showMessageDialog(null,"Cancel, X or escape key selected"); • else JOptionPane.showMessageDialog(null,"Your password is "+new String(pwd.getPassword())); • System.exit(0); • } • public static void main(String args[]) • {jpswrd p= new jpswrd(); • p.Testing();} • }
  • 24. • setEchoChar('+'); • Set character for password field.
  • 25. JFrame • A Frame is a top-level window with a title and a border. • Frame that adds support for the Swing component architecture.
  • 26. JFrame Features  It’s a window with title, border, (optional) menu bar and user-specified components. .It can be moved, resized, iconified. .It is not a subclass of JComponent. .Delegates responsibility of managing user- specified components to a content pane, an instance of JPanel.
  • 27. Centering JFrame’s • By default, a Jframe is displayed in the upper- left corner of the screen. To display a frame at a specified location, you can use the setLocation(x, y) method in the JFrame class. This method places the upper-left corner of a frame at location (x, y).
  • 28. Class constructors • JFrame() Constructs a new frame that is initially invisible. • JFrame(String title) Creates a new, initially invisible Frame with the specified title.
  • 29. JButton • A button is a component the user clicks to trigger a specific action. A Java application can use several types of buttons, including command buttons, checkboxes, toggle buttons and radio buttons.
  • 30. • all the button types are subclasses of AbstractButton (package javax.swing), which declares the common features of Swing buttons.
  • 31.
  • 32. Buttons That Maintain State • The Swing GUI components contain three types of state buttons—JToggleButton, • JCheckBox and JRadioButton—that have on/off or true/false values. Classes JCheckBox and JRadioButton are subclasses of JToggleButton
  • 33. JLabel • A JLabel displays read-only text, an image, or both text and an image.
  • 34. JFileChooser Allows the the user to choose a file • import javax.swing.JFileChooser; • public class swing_examples { • public static void main(String args[]) • { • JFileChooser fc = new JFileChooser(); • int returnVal = fc.showOpenDialog(null); • if(returnVal == JFileChooser.APPROVE_OPTION) • System.out.println("File: " + fc.getSelectedFile()); • } • }
  • 35. JCheckBox Class • The class JCheckBox is an implementation of a check box - an item that can be selected or deselected, and which displays its state to the user.
  • 37.
  • 38.
  • 40. /*code for checkbox that display bold text*/ • font=new Font("",Font.BOLD,14); • jTextField1.setFont(font); • /*code for checkbox that display italic text*/ • font=new Font("",Font.ITALIC,14); • jTextField1.setFont(font);
  • 41.
  • 42.
  • 43. JRadio Button • The class JRadioButton is an implementation of a radio button - an item that can be selected or deselected, and which displays its state to the user.
  • 44.
  • 45. Mathematical Operations using Radio Buttons • private void jButton1ActionPerformed(java.awt.event.Acti onEvent evt) { • jTextField1.setText(""); • jTextField2.setText(""); • jTextField3.setText("");
  • 46. Addition RadioButton • private void jRadioButton1ActionPerformed(java.awt.event.A ctionEvent evt) { • int num1,num2,result; • num1=Integer.parseInt(jTextField1.getText()); • num2=Integer.parseInt(jTextField2.getText()); • result=num1+num2; • jTextField3.setText(String.valueOf(result));
  • 47. Multiplication RadioButton • private void jRadioButton2ActionPerformed(java.awt.event.A ctionEvent evt) { • int num1,num2,result; • num1=Integer.parseInt(jTextField1.getText()); • num2=Integer.parseInt(jTextField2.getText()); • result=num1*num2; • jTextField3.setText(String.valueOf(result)); // TODO add your handling code here: • }
  • 48. Subtraction RadioButton • private void jRadioButton3ActionPerformed(java.awt.event.A ctionEvent evt) { • int num1,num2,result; • num1=Integer.parseInt(jTextField1.getText()); • num2=Integer.parseInt(jTextField2.getText()); • result=num1-num2; • jTextField3.setText(String.valueOf(result)); // TODO add your handling code here: • }