SlideShare a Scribd company logo
package buttongui;
import static com.sun.deploy.config.JREInfo.clear;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class ButtonGUI extends Application implements EventHandler {
@Override
public void start(Stage primaryStage) {
btn.setText("Find");
btn.setOnAction(this);
btn1.setText("Clear");
btn1.setOnAction(this);
btn2.setText("Exit");
btn2.setOnAction(this);
FlowPane flow = new FlowPane();
flow.getChildren().addAll(btn,btn1,btn2);
BorderPane border = new BorderPane();
border.setCenter(flow);
Scene scene = new Scene(border, 300,250);
primaryStage.setTitle("ButtonGUI");
primaryStage.setScene(scene);
primaryStage.show();
}
@Override
public void handle(ActionEvent event) {
String tx ="Hello world";
System.out.println(tx);
if(btn2 == event.getSource()){
System.out.println("Exit Pressed");
System.exit(0);
}
}
public static void main(String[] args)throws Exception {
launch(args);
}
}
Simple Exit & Clear Events) Add the Exit Event to your ButtonsGUI. Make it so that when the
user clicks on the Exit button, the application ends. Add the Clear Event to your ButtonsGUI.
Make it so that when the user clicks on the Clear button, the Text on all the Buttons is cleared.
please solve the clear button so that when the user clicks on the Clear button, the Text on all the
Buttons is cleared. thanks
Solution
Follow below steps to Add the Exit Event to your Buttons GUI:
1. Right Click on the Exit button and choose Events --> Action --> ActionPerformed.
2. The IDE will automatically add an ActionListener to the Exit button and generate a handler
method for handling the listener's actionPerformed method.
3. The IDE will open up the Source Code window and scroll to where you implement the action
you want the button to do when the button is pressed.
4. Add code for what we want the Exit Button to do. You will have to type System.exit(0);
5. Your final Exit button code should look like this:
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt)
{
System.exit(0);
}
Follow below steps to Add the Clear Event to your Buttons GUI:
In below example the text in two of our jTextFields will clear, it is overwriting the existing Text
with a blank.
1. Click on the Design tab at the top of your work area to go back to the Form Design
2. Right Click on the Clear button (jButton1). From the pop-up menu select Events --> Action --
> ActionPerformed.
3. Your final source code will be:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
{
jTextField1.setText("");
jTextField2.setText("");
}
Note: You can add as many jTextField depending upon number of buttons you have

More Related Content

Similar to package buttongui; import static com.sun.deploy.config.JREInf.pdf

CORE JAVA-2
CORE JAVA-2CORE JAVA-2
Program klik sederhana
Program klik sederhanaProgram klik sederhana
Program klik sederhana
Henfry Kai
 
I am getting a syntax error. I cant seem to find whats causing t.pdf
I am getting a syntax error. I cant seem to find whats causing t.pdfI am getting a syntax error. I cant seem to find whats causing t.pdf
I am getting a syntax error. I cant seem to find whats causing t.pdf
fashionfolionr
 
ITE 1122_ Event Handling.pptx
ITE 1122_ Event Handling.pptxITE 1122_ Event Handling.pptx
ITE 1122_ Event Handling.pptx
udithaisur
 
Swing
SwingSwing
Swing
Nataraj Dg
 
engineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.pptengineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.ppt
sharanyak0721
 
Lecture8 oopj
Lecture8 oopjLecture8 oopj
Lecture8 oopj
Dhairya Joshi
 
Md11 gui event handling
Md11 gui event handlingMd11 gui event handling
Md11 gui event handling
Rakesh Madugula
 
Basic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in JavaBasic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in Java
suraj pandey
 
ch20.pptx
ch20.pptxch20.pptx
Enhance the ButtonViewer program so that it prints the time at which t.docx
Enhance the ButtonViewer program so that it prints the time at which t.docxEnhance the ButtonViewer program so that it prints the time at which t.docx
Enhance the ButtonViewer program so that it prints the time at which t.docx
todd401
 
java2 swing
java2 swingjava2 swing
java2 swing
guest0282b71
 
Violet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole TeamViolet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole Team
Anton Caceres
 
UNIT 5-JavaFX Event Handling, Controls and Components.pdf
UNIT 5-JavaFX Event Handling, Controls and Components.pdfUNIT 5-JavaFX Event Handling, Controls and Components.pdf
UNIT 5-JavaFX Event Handling, Controls and Components.pdf
SakkaravarthiS1
 
Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3
martha leon
 
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton ClassesJava Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
OXUS 20
 
Assignment InstructionsInstructions Make sure you go t
Assignment InstructionsInstructions Make sure you go tAssignment InstructionsInstructions Make sure you go t
Assignment InstructionsInstructions Make sure you go t
widdowsonerica
 
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)
Daroko blog(www.professionalbloggertricks.com)
 
The java swing_tutorial
The java swing_tutorialThe java swing_tutorial
The java swing_tutorial
sumitjoshi01
 
event-handling.pptx
event-handling.pptxevent-handling.pptx
event-handling.pptx
Good657694
 

Similar to package buttongui; import static com.sun.deploy.config.JREInf.pdf (20)

CORE JAVA-2
CORE JAVA-2CORE JAVA-2
CORE JAVA-2
 
Program klik sederhana
Program klik sederhanaProgram klik sederhana
Program klik sederhana
 
I am getting a syntax error. I cant seem to find whats causing t.pdf
I am getting a syntax error. I cant seem to find whats causing t.pdfI am getting a syntax error. I cant seem to find whats causing t.pdf
I am getting a syntax error. I cant seem to find whats causing t.pdf
 
ITE 1122_ Event Handling.pptx
ITE 1122_ Event Handling.pptxITE 1122_ Event Handling.pptx
ITE 1122_ Event Handling.pptx
 
Swing
SwingSwing
Swing
 
engineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.pptengineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.ppt
 
Lecture8 oopj
Lecture8 oopjLecture8 oopj
Lecture8 oopj
 
Md11 gui event handling
Md11 gui event handlingMd11 gui event handling
Md11 gui event handling
 
Basic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in JavaBasic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in Java
 
ch20.pptx
ch20.pptxch20.pptx
ch20.pptx
 
Enhance the ButtonViewer program so that it prints the time at which t.docx
Enhance the ButtonViewer program so that it prints the time at which t.docxEnhance the ButtonViewer program so that it prints the time at which t.docx
Enhance the ButtonViewer program so that it prints the time at which t.docx
 
java2 swing
java2 swingjava2 swing
java2 swing
 
Violet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole TeamViolet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole Team
 
UNIT 5-JavaFX Event Handling, Controls and Components.pdf
UNIT 5-JavaFX Event Handling, Controls and Components.pdfUNIT 5-JavaFX Event Handling, Controls and Components.pdf
UNIT 5-JavaFX Event Handling, Controls and Components.pdf
 
Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3
 
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton ClassesJava Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
 
Assignment InstructionsInstructions Make sure you go t
Assignment InstructionsInstructions Make sure you go tAssignment InstructionsInstructions Make sure you go t
Assignment InstructionsInstructions Make sure you go t
 
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)
 
The java swing_tutorial
The java swing_tutorialThe java swing_tutorial
The java swing_tutorial
 
event-handling.pptx
event-handling.pptxevent-handling.pptx
event-handling.pptx
 

More from arjuntiwari586

Would you recomend that Miss E begin to take a vitamin or mineral su.pdf
Would you recomend that Miss E begin to take a vitamin or mineral su.pdfWould you recomend that Miss E begin to take a vitamin or mineral su.pdf
Would you recomend that Miss E begin to take a vitamin or mineral su.pdf
arjuntiwari586
 
Which perspective best describes adolescenceWhen does adolescence.pdf
Which perspective best describes adolescenceWhen does adolescence.pdfWhich perspective best describes adolescenceWhen does adolescence.pdf
Which perspective best describes adolescenceWhen does adolescence.pdf
arjuntiwari586
 
Which of the following is a trace element, required only in small amo.pdf
Which of the following is a trace element, required only in small amo.pdfWhich of the following is a trace element, required only in small amo.pdf
Which of the following is a trace element, required only in small amo.pdf
arjuntiwari586
 
Which of the following enzymes has the ability to accomplish all thr.pdf
Which of the following enzymes has the ability to accomplish all thr.pdfWhich of the following enzymes has the ability to accomplish all thr.pdf
Which of the following enzymes has the ability to accomplish all thr.pdf
arjuntiwari586
 
What risk are associated with pregnancySolutionThere are vari.pdf
What risk are associated with pregnancySolutionThere are vari.pdfWhat risk are associated with pregnancySolutionThere are vari.pdf
What risk are associated with pregnancySolutionThere are vari.pdf
arjuntiwari586
 
What are the relative signal intensities for Grey and White matter u.pdf
What are the relative signal intensities for Grey and White matter u.pdfWhat are the relative signal intensities for Grey and White matter u.pdf
What are the relative signal intensities for Grey and White matter u.pdf
arjuntiwari586
 
What is the ovum doing during the primary oocyte stageSolution.pdf
What is the ovum doing during the primary oocyte stageSolution.pdfWhat is the ovum doing during the primary oocyte stageSolution.pdf
What is the ovum doing during the primary oocyte stageSolution.pdf
arjuntiwari586
 
What is the structural difference between the sugar found in RNA and.pdf
What is the structural difference between the sugar found in RNA and.pdfWhat is the structural difference between the sugar found in RNA and.pdf
What is the structural difference between the sugar found in RNA and.pdf
arjuntiwari586
 
uìdyov fotect peaga e (or ways co profecé se p protect e . Haa .pdf
uìdyov fotect peaga e (or ways co profecé se p protect e . Haa .pdfuìdyov fotect peaga e (or ways co profecé se p protect e . Haa .pdf
uìdyov fotect peaga e (or ways co profecé se p protect e . Haa .pdf
arjuntiwari586
 
Use the Java Thread class to demonstrate the following functionaliti.pdf
Use the Java Thread class to demonstrate the following functionaliti.pdfUse the Java Thread class to demonstrate the following functionaliti.pdf
Use the Java Thread class to demonstrate the following functionaliti.pdf
arjuntiwari586
 
Turner suppressor genes.... prevent gene expression of oncogenes. pre.pdf
Turner suppressor genes.... prevent gene expression of oncogenes. pre.pdfTurner suppressor genes.... prevent gene expression of oncogenes. pre.pdf
Turner suppressor genes.... prevent gene expression of oncogenes. pre.pdf
arjuntiwari586
 
This image is a reminder that statistical significant is often set at.pdf
This image is a reminder that statistical significant is often set at.pdfThis image is a reminder that statistical significant is often set at.pdf
This image is a reminder that statistical significant is often set at.pdf
arjuntiwari586
 
The state diagram shown up corresponds to a circuit implementation th.pdf
The state diagram shown up corresponds to a circuit implementation th.pdfThe state diagram shown up corresponds to a circuit implementation th.pdf
The state diagram shown up corresponds to a circuit implementation th.pdf
arjuntiwari586
 
The lineage that produced chimpanzees and humans split from other pri.pdf
The lineage that produced chimpanzees and humans split from other pri.pdfThe lineage that produced chimpanzees and humans split from other pri.pdf
The lineage that produced chimpanzees and humans split from other pri.pdf
arjuntiwari586
 
production deviance postconventional level primary stakeholders perso.pdf
production deviance postconventional level primary stakeholders perso.pdfproduction deviance postconventional level primary stakeholders perso.pdf
production deviance postconventional level primary stakeholders perso.pdf
arjuntiwari586
 
Question 19 (1 point) The DuPont identity breaks down return on equit.pdf
Question 19 (1 point) The DuPont identity breaks down return on equit.pdfQuestion 19 (1 point) The DuPont identity breaks down return on equit.pdf
Question 19 (1 point) The DuPont identity breaks down return on equit.pdf
arjuntiwari586
 
Prepare a 3-4 page, double-spaced paper (cite 3-4 reliable sources) .pdf
Prepare a 3-4 page, double-spaced paper (cite 3-4 reliable sources) .pdfPrepare a 3-4 page, double-spaced paper (cite 3-4 reliable sources) .pdf
Prepare a 3-4 page, double-spaced paper (cite 3-4 reliable sources) .pdf
arjuntiwari586
 
need help with this java lab please read below and follow the steps.pdf
need help with this java lab please read below and follow the steps.pdfneed help with this java lab please read below and follow the steps.pdf
need help with this java lab please read below and follow the steps.pdf
arjuntiwari586
 
Place all the characteristics of living organisms the answer box. Ch.pdf
Place all the characteristics of living organisms the answer box.  Ch.pdfPlace all the characteristics of living organisms the answer box.  Ch.pdf
Place all the characteristics of living organisms the answer box. Ch.pdf
arjuntiwari586
 
LABELING ACTIVITY 2 (Rs 1-10) 10 10. 12. 13 14, 15 16 62 circulatory .pdf
LABELING ACTIVITY 2 (Rs 1-10) 10 10. 12. 13 14, 15 16 62 circulatory .pdfLABELING ACTIVITY 2 (Rs 1-10) 10 10. 12. 13 14, 15 16 62 circulatory .pdf
LABELING ACTIVITY 2 (Rs 1-10) 10 10. 12. 13 14, 15 16 62 circulatory .pdf
arjuntiwari586
 

More from arjuntiwari586 (20)

Would you recomend that Miss E begin to take a vitamin or mineral su.pdf
Would you recomend that Miss E begin to take a vitamin or mineral su.pdfWould you recomend that Miss E begin to take a vitamin or mineral su.pdf
Would you recomend that Miss E begin to take a vitamin or mineral su.pdf
 
Which perspective best describes adolescenceWhen does adolescence.pdf
Which perspective best describes adolescenceWhen does adolescence.pdfWhich perspective best describes adolescenceWhen does adolescence.pdf
Which perspective best describes adolescenceWhen does adolescence.pdf
 
Which of the following is a trace element, required only in small amo.pdf
Which of the following is a trace element, required only in small amo.pdfWhich of the following is a trace element, required only in small amo.pdf
Which of the following is a trace element, required only in small amo.pdf
 
Which of the following enzymes has the ability to accomplish all thr.pdf
Which of the following enzymes has the ability to accomplish all thr.pdfWhich of the following enzymes has the ability to accomplish all thr.pdf
Which of the following enzymes has the ability to accomplish all thr.pdf
 
What risk are associated with pregnancySolutionThere are vari.pdf
What risk are associated with pregnancySolutionThere are vari.pdfWhat risk are associated with pregnancySolutionThere are vari.pdf
What risk are associated with pregnancySolutionThere are vari.pdf
 
What are the relative signal intensities for Grey and White matter u.pdf
What are the relative signal intensities for Grey and White matter u.pdfWhat are the relative signal intensities for Grey and White matter u.pdf
What are the relative signal intensities for Grey and White matter u.pdf
 
What is the ovum doing during the primary oocyte stageSolution.pdf
What is the ovum doing during the primary oocyte stageSolution.pdfWhat is the ovum doing during the primary oocyte stageSolution.pdf
What is the ovum doing during the primary oocyte stageSolution.pdf
 
What is the structural difference between the sugar found in RNA and.pdf
What is the structural difference between the sugar found in RNA and.pdfWhat is the structural difference between the sugar found in RNA and.pdf
What is the structural difference between the sugar found in RNA and.pdf
 
uìdyov fotect peaga e (or ways co profecé se p protect e . Haa .pdf
uìdyov fotect peaga e (or ways co profecé se p protect e . Haa .pdfuìdyov fotect peaga e (or ways co profecé se p protect e . Haa .pdf
uìdyov fotect peaga e (or ways co profecé se p protect e . Haa .pdf
 
Use the Java Thread class to demonstrate the following functionaliti.pdf
Use the Java Thread class to demonstrate the following functionaliti.pdfUse the Java Thread class to demonstrate the following functionaliti.pdf
Use the Java Thread class to demonstrate the following functionaliti.pdf
 
Turner suppressor genes.... prevent gene expression of oncogenes. pre.pdf
Turner suppressor genes.... prevent gene expression of oncogenes. pre.pdfTurner suppressor genes.... prevent gene expression of oncogenes. pre.pdf
Turner suppressor genes.... prevent gene expression of oncogenes. pre.pdf
 
This image is a reminder that statistical significant is often set at.pdf
This image is a reminder that statistical significant is often set at.pdfThis image is a reminder that statistical significant is often set at.pdf
This image is a reminder that statistical significant is often set at.pdf
 
The state diagram shown up corresponds to a circuit implementation th.pdf
The state diagram shown up corresponds to a circuit implementation th.pdfThe state diagram shown up corresponds to a circuit implementation th.pdf
The state diagram shown up corresponds to a circuit implementation th.pdf
 
The lineage that produced chimpanzees and humans split from other pri.pdf
The lineage that produced chimpanzees and humans split from other pri.pdfThe lineage that produced chimpanzees and humans split from other pri.pdf
The lineage that produced chimpanzees and humans split from other pri.pdf
 
production deviance postconventional level primary stakeholders perso.pdf
production deviance postconventional level primary stakeholders perso.pdfproduction deviance postconventional level primary stakeholders perso.pdf
production deviance postconventional level primary stakeholders perso.pdf
 
Question 19 (1 point) The DuPont identity breaks down return on equit.pdf
Question 19 (1 point) The DuPont identity breaks down return on equit.pdfQuestion 19 (1 point) The DuPont identity breaks down return on equit.pdf
Question 19 (1 point) The DuPont identity breaks down return on equit.pdf
 
Prepare a 3-4 page, double-spaced paper (cite 3-4 reliable sources) .pdf
Prepare a 3-4 page, double-spaced paper (cite 3-4 reliable sources) .pdfPrepare a 3-4 page, double-spaced paper (cite 3-4 reliable sources) .pdf
Prepare a 3-4 page, double-spaced paper (cite 3-4 reliable sources) .pdf
 
need help with this java lab please read below and follow the steps.pdf
need help with this java lab please read below and follow the steps.pdfneed help with this java lab please read below and follow the steps.pdf
need help with this java lab please read below and follow the steps.pdf
 
Place all the characteristics of living organisms the answer box. Ch.pdf
Place all the characteristics of living organisms the answer box.  Ch.pdfPlace all the characteristics of living organisms the answer box.  Ch.pdf
Place all the characteristics of living organisms the answer box. Ch.pdf
 
LABELING ACTIVITY 2 (Rs 1-10) 10 10. 12. 13 14, 15 16 62 circulatory .pdf
LABELING ACTIVITY 2 (Rs 1-10) 10 10. 12. 13 14, 15 16 62 circulatory .pdfLABELING ACTIVITY 2 (Rs 1-10) 10 10. 12. 13 14, 15 16 62 circulatory .pdf
LABELING ACTIVITY 2 (Rs 1-10) 10 10. 12. 13 14, 15 16 62 circulatory .pdf
 

Recently uploaded

Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 

Recently uploaded (20)

Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 

package buttongui; import static com.sun.deploy.config.JREInf.pdf

  • 1. package buttongui; import static com.sun.deploy.config.JREInfo.clear; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Menu; import javafx.scene.control.MenuBar; import javafx.scene.control.MenuItem; import javafx.scene.layout.BorderPane; import javafx.scene.layout.FlowPane; import javafx.scene.layout.StackPane; import javafx.stage.Stage; public class ButtonGUI extends Application implements EventHandler { @Override public void start(Stage primaryStage) { btn.setText("Find"); btn.setOnAction(this); btn1.setText("Clear"); btn1.setOnAction(this); btn2.setText("Exit"); btn2.setOnAction(this); FlowPane flow = new FlowPane(); flow.getChildren().addAll(btn,btn1,btn2); BorderPane border = new BorderPane(); border.setCenter(flow);
  • 2. Scene scene = new Scene(border, 300,250); primaryStage.setTitle("ButtonGUI"); primaryStage.setScene(scene); primaryStage.show(); } @Override public void handle(ActionEvent event) { String tx ="Hello world"; System.out.println(tx); if(btn2 == event.getSource()){ System.out.println("Exit Pressed"); System.exit(0); } } public static void main(String[] args)throws Exception { launch(args); } } Simple Exit & Clear Events) Add the Exit Event to your ButtonsGUI. Make it so that when the user clicks on the Exit button, the application ends. Add the Clear Event to your ButtonsGUI. Make it so that when the user clicks on the Clear button, the Text on all the Buttons is cleared. please solve the clear button so that when the user clicks on the Clear button, the Text on all the Buttons is cleared. thanks Solution Follow below steps to Add the Exit Event to your Buttons GUI: 1. Right Click on the Exit button and choose Events --> Action --> ActionPerformed. 2. The IDE will automatically add an ActionListener to the Exit button and generate a handler
  • 3. method for handling the listener's actionPerformed method. 3. The IDE will open up the Source Code window and scroll to where you implement the action you want the button to do when the button is pressed. 4. Add code for what we want the Exit Button to do. You will have to type System.exit(0); 5. Your final Exit button code should look like this: private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { System.exit(0); } Follow below steps to Add the Clear Event to your Buttons GUI: In below example the text in two of our jTextFields will clear, it is overwriting the existing Text with a blank. 1. Click on the Design tab at the top of your work area to go back to the Form Design 2. Right Click on the Clear button (jButton1). From the pop-up menu select Events --> Action -- > ActionPerformed. 3. Your final source code will be: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { jTextField1.setText(""); jTextField2.setText(""); } Note: You can add as many jTextField depending upon number of buttons you have