SlideShare a Scribd company logo
1 of 4
Download to read offline
Question 5: Checkboxes,Radio Buttons, and JTextArea
Write a program to allow the user to enter their name (using a text field), age (using a text field),
gender (using radio buttons), and whether they are a student (using a check box). Include a
submit button. When the user clicks submit, display a summary of the information in a text area.
Solution
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package example;
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.control.Toggle;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
/**
*
* @author MARIYABABU
*/
public class Example extends Application {
@Override
public void start(Stage primaryStage) {
GridPane grid = new GridPane();
grid.setAlignment(Pos.CENTER);
grid.setHgap(10);
grid.setVgap(10);
Label name = new Label("your Name:");
grid.add(name, 0, 0);
TextField tname = new TextField();
grid.add(tname, 1, 0);
Label age = new Label("Your age:");
grid.add(age, 0, 1);
TextField tage = new TextField();
grid.add(tage, 1, 1);
Label gender = new Label("Your Gender:");
grid.add(gender, 0, 2);
ToggleGroup pickGender = new ToggleGroup();
RadioButton pickMale = new RadioButton("Male");
pickMale.setToggleGroup(pickGender);
pickMale.setSelected(true);
grid.add(pickMale,1,2);
RadioButton pickFemale = new RadioButton("Female");
pickFemale.setToggleGroup(pickGender);
grid.add(pickFemale,2, 2);
Label std = new Label("Are you a Student?:");
grid.add(std, 0, 3);
CheckBox cb1 = new CheckBox("Student");
grid.add(cb1,1,3);
CheckBox cb2 = new CheckBox("Employee");
grid.add(cb2,2,3);
Label summa = new Label("Summary");
grid.add(summa, 0, 4);
TextArea summary = new TextArea();
grid.add(summary, 0, 5);
Button btn = new Button();
btn.setText("GET SUMMARY");
btn.setOnAction(new EventHandler() {
@Override
public void handle(ActionEvent event) {
summary.setText(
"Name :"+tname.getText()+" "+"age :"+tage.getText()+" ");
//summary.appendText(name.getText());
System.out.println("I am doing Well");
}
});
//final ToggleGroup group = new ToggleGroup();
pickGender.selectedToggleProperty().addListener(new ChangeListener(){
@Override
public void changed(ObservableValue ov,
Toggle old_toggle, Toggle new_toggle) {
if (pickGender.getSelectedToggle() != null) {
summary.appendText(" Gender :"+pickGender.getSelectedToggle().getUserData().toString());
}
}
});
grid.add(btn,1,4);
Scene scene = new Scene(grid, 500, 500);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}

More Related Content

Similar to Question 5 Checkboxes,Radio Buttons, and JTextAreaWrite a program.pdf

Prg 421 entire course
Prg 421 entire coursePrg 421 entire course
Prg 421 entire course
ACC421
 
Cis 355 ilab 4 of 6
Cis 355 ilab 4 of 6Cis 355 ilab 4 of 6
Cis 355 ilab 4 of 6
comp274
 
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
 
The task is to design and develop a prototype for one of the fea.docx
The task is to design and develop a prototype for one of the fea.docxThe task is to design and develop a prototype for one of the fea.docx
The task is to design and develop a prototype for one of the fea.docx
sarah98765
 
You can look at the Java programs in the text book to see how commen
You can look at the Java programs in the text book to see how commenYou can look at the Java programs in the text book to see how commen
You can look at the Java programs in the text book to see how commen
anitramcroberts
 
2) java development
2) java development2) java development
2) java development
techbed
 
Cis 355 i lab 4 of 6
Cis 355 i lab 4 of 6Cis 355 i lab 4 of 6
Cis 355 i lab 4 of 6
helpido9
 
Task(s)The task is to design and develop a prototype for one.docx
Task(s)The task is to design and develop a prototype for one.docxTask(s)The task is to design and develop a prototype for one.docx
Task(s)The task is to design and develop a prototype for one.docx
josies1
 

Similar to Question 5 Checkboxes,Radio Buttons, and JTextAreaWrite a program.pdf (20)

Prg 421 entire course
Prg 421 entire coursePrg 421 entire course
Prg 421 entire course
 
Cis 406 Technology levels--snaptutorial.com
Cis 406 Technology levels--snaptutorial.comCis 406 Technology levels--snaptutorial.com
Cis 406 Technology levels--snaptutorial.com
 
Cis 406 Success Begins / snaptutorial.com
Cis 406 Success Begins / snaptutorial.comCis 406 Success Begins / snaptutorial.com
Cis 406 Success Begins / snaptutorial.com
 
Cis 406 Enthusiastic Study - snaptutorial.com
Cis 406 Enthusiastic Study - snaptutorial.comCis 406 Enthusiastic Study - snaptutorial.com
Cis 406 Enthusiastic Study - snaptutorial.com
 
Cis 355 ilab 4 of 6
Cis 355 ilab 4 of 6Cis 355 ilab 4 of 6
Cis 355 ilab 4 of 6
 
Android Application Development - Level 2
Android Application Development - Level 2Android Application Development - Level 2
Android Application Development - Level 2
 
QTP Functions
QTP FunctionsQTP Functions
QTP Functions
 
Gui programming a review - mixed content
Gui programming   a review - mixed contentGui programming   a review - mixed content
Gui programming a review - mixed content
 
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
 
GUI programming
GUI programmingGUI programming
GUI programming
 
CIS 406 Effective Communication - tutorialrank.com
CIS 406 Effective Communication - tutorialrank.comCIS 406 Effective Communication - tutorialrank.com
CIS 406 Effective Communication - tutorialrank.com
 
React Hooks Best Practices in 2022.pptx
React Hooks Best Practices in 2022.pptxReact Hooks Best Practices in 2022.pptx
React Hooks Best Practices in 2022.pptx
 
The task is to design and develop a prototype for one of the fea.docx
The task is to design and develop a prototype for one of the fea.docxThe task is to design and develop a prototype for one of the fea.docx
The task is to design and develop a prototype for one of the fea.docx
 
Chap1 1 1
Chap1 1 1Chap1 1 1
Chap1 1 1
 
Chap1 1.1
Chap1 1.1Chap1 1.1
Chap1 1.1
 
You can look at the Java programs in the text book to see how commen
You can look at the Java programs in the text book to see how commenYou can look at the Java programs in the text book to see how commen
You can look at the Java programs in the text book to see how commen
 
2) java development
2) java development2) java development
2) java development
 
CIS 406 Entire Course NEW
CIS 406 Entire Course NEWCIS 406 Entire Course NEW
CIS 406 Entire Course NEW
 
Cis 355 i lab 4 of 6
Cis 355 i lab 4 of 6Cis 355 i lab 4 of 6
Cis 355 i lab 4 of 6
 
Task(s)The task is to design and develop a prototype for one.docx
Task(s)The task is to design and develop a prototype for one.docxTask(s)The task is to design and develop a prototype for one.docx
Task(s)The task is to design and develop a prototype for one.docx
 

More from arkleatheray

Determine whether the following statements about the accumulated eang.pdf
Determine whether the following statements about the accumulated eang.pdfDetermine whether the following statements about the accumulated eang.pdf
Determine whether the following statements about the accumulated eang.pdf
arkleatheray
 
Data StructuresPlease I need help completing this c++ program..pdf
Data StructuresPlease I need help completing this c++ program..pdfData StructuresPlease I need help completing this c++ program..pdf
Data StructuresPlease I need help completing this c++ program..pdf
arkleatheray
 
Create Student Project Database with insert, select, update, and del.pdf
Create Student Project Database with insert, select, update, and del.pdfCreate Student Project Database with insert, select, update, and del.pdf
Create Student Project Database with insert, select, update, and del.pdf
arkleatheray
 
Before 1980, most cell control and management software was written b.pdf
Before 1980, most cell control and management software was written b.pdfBefore 1980, most cell control and management software was written b.pdf
Before 1980, most cell control and management software was written b.pdf
arkleatheray
 
^^^Q3. I am trying to implement double linked list but I was faile.pdf
^^^Q3. I am trying to implement double linked list but I was faile.pdf^^^Q3. I am trying to implement double linked list but I was faile.pdf
^^^Q3. I am trying to implement double linked list but I was faile.pdf
arkleatheray
 
What is the evolutionary basis for sexual reproductionSolution.pdf
What is the evolutionary basis for sexual reproductionSolution.pdfWhat is the evolutionary basis for sexual reproductionSolution.pdf
What is the evolutionary basis for sexual reproductionSolution.pdf
arkleatheray
 
Why is it that the Grams stain is not appropriate for acid fast ba.pdf
Why is it that the Grams stain is not appropriate for acid fast ba.pdfWhy is it that the Grams stain is not appropriate for acid fast ba.pdf
Why is it that the Grams stain is not appropriate for acid fast ba.pdf
arkleatheray
 
Why does this version of the swap function fail to work Is there a f.pdf
Why does this version of the swap function fail to work Is there a f.pdfWhy does this version of the swap function fail to work Is there a f.pdf
Why does this version of the swap function fail to work Is there a f.pdf
arkleatheray
 
The groin is also known as the _____ region. crural inguinal perin.pdf
The groin is also known as the _____ region.  crural  inguinal  perin.pdfThe groin is also known as the _____ region.  crural  inguinal  perin.pdf
The groin is also known as the _____ region. crural inguinal perin.pdf
arkleatheray
 

More from arkleatheray (20)

briefly write about the Aridity of Subtropics Causes, locations, etc.pdf
briefly write about the Aridity of Subtropics Causes, locations, etc.pdfbriefly write about the Aridity of Subtropics Causes, locations, etc.pdf
briefly write about the Aridity of Subtropics Causes, locations, etc.pdf
 
Compare and contrast the Mann-Whitney (aka Wilcoxon Rank Sum) Test w.pdf
Compare and contrast the Mann-Whitney (aka Wilcoxon Rank Sum) Test w.pdfCompare and contrast the Mann-Whitney (aka Wilcoxon Rank Sum) Test w.pdf
Compare and contrast the Mann-Whitney (aka Wilcoxon Rank Sum) Test w.pdf
 
Determine whether the following statements about the accumulated eang.pdf
Determine whether the following statements about the accumulated eang.pdfDetermine whether the following statements about the accumulated eang.pdf
Determine whether the following statements about the accumulated eang.pdf
 
Discuss the changing demographics of Entrepreneurs and give an examp.pdf
Discuss the changing demographics of Entrepreneurs and give an examp.pdfDiscuss the changing demographics of Entrepreneurs and give an examp.pdf
Discuss the changing demographics of Entrepreneurs and give an examp.pdf
 
Data StructuresPlease I need help completing this c++ program..pdf
Data StructuresPlease I need help completing this c++ program..pdfData StructuresPlease I need help completing this c++ program..pdf
Data StructuresPlease I need help completing this c++ program..pdf
 
Create Student Project Database with insert, select, update, and del.pdf
Create Student Project Database with insert, select, update, and del.pdfCreate Student Project Database with insert, select, update, and del.pdf
Create Student Project Database with insert, select, update, and del.pdf
 
Before 1980, most cell control and management software was written b.pdf
Before 1980, most cell control and management software was written b.pdfBefore 1980, most cell control and management software was written b.pdf
Before 1980, most cell control and management software was written b.pdf
 
at age 51 can you take early distributions from traditional IRA for .pdf
at age 51 can you take early distributions from traditional IRA for .pdfat age 51 can you take early distributions from traditional IRA for .pdf
at age 51 can you take early distributions from traditional IRA for .pdf
 
What is a view What is it used for Give examples when a view can b.pdf
What is a view What is it used for Give examples when a view can b.pdfWhat is a view What is it used for Give examples when a view can b.pdf
What is a view What is it used for Give examples when a view can b.pdf
 
^^^Q3. I am trying to implement double linked list but I was faile.pdf
^^^Q3. I am trying to implement double linked list but I was faile.pdf^^^Q3. I am trying to implement double linked list but I was faile.pdf
^^^Q3. I am trying to implement double linked list but I was faile.pdf
 
What is the evolutionary basis for sexual reproductionSolution.pdf
What is the evolutionary basis for sexual reproductionSolution.pdfWhat is the evolutionary basis for sexual reproductionSolution.pdf
What is the evolutionary basis for sexual reproductionSolution.pdf
 
Why is it that the Grams stain is not appropriate for acid fast ba.pdf
Why is it that the Grams stain is not appropriate for acid fast ba.pdfWhy is it that the Grams stain is not appropriate for acid fast ba.pdf
Why is it that the Grams stain is not appropriate for acid fast ba.pdf
 
Why does this version of the swap function fail to work Is there a f.pdf
Why does this version of the swap function fail to work Is there a f.pdfWhy does this version of the swap function fail to work Is there a f.pdf
Why does this version of the swap function fail to work Is there a f.pdf
 
Which of the following is NOT a reason why heat is a bad method to ov.pdf
Which of the following is NOT a reason why heat is a bad method to ov.pdfWhich of the following is NOT a reason why heat is a bad method to ov.pdf
Which of the following is NOT a reason why heat is a bad method to ov.pdf
 
What are the trends in browsersSolution1.chrome Google chrom.pdf
What are the trends in browsersSolution1.chrome Google chrom.pdfWhat are the trends in browsersSolution1.chrome Google chrom.pdf
What are the trends in browsersSolution1.chrome Google chrom.pdf
 
The probability of a persons being left-handed is .12. In the 1992.pdf
The probability of a persons being left-handed is .12. In the 1992.pdfThe probability of a persons being left-handed is .12. In the 1992.pdf
The probability of a persons being left-handed is .12. In the 1992.pdf
 
The mass of a radioactive substance follows a continuous exponential.pdf
The mass of a radioactive substance follows a continuous exponential.pdfThe mass of a radioactive substance follows a continuous exponential.pdf
The mass of a radioactive substance follows a continuous exponential.pdf
 
The groin is also known as the _____ region. crural inguinal perin.pdf
The groin is also known as the _____ region.  crural  inguinal  perin.pdfThe groin is also known as the _____ region.  crural  inguinal  perin.pdf
The groin is also known as the _____ region. crural inguinal perin.pdf
 
short answer List and describe two advances during the Industrial Re.pdf
short answer List and describe two advances during the Industrial Re.pdfshort answer List and describe two advances during the Industrial Re.pdf
short answer List and describe two advances during the Industrial Re.pdf
 
SheilaSalmonella agar is _ because _ breaks down amino acids that co.pdf
SheilaSalmonella agar is _ because _ breaks down amino acids that co.pdfSheilaSalmonella agar is _ because _ breaks down amino acids that co.pdf
SheilaSalmonella agar is _ because _ breaks down amino acids that co.pdf
 

Recently uploaded

Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
EADTU
 

Recently uploaded (20)

An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 

Question 5 Checkboxes,Radio Buttons, and JTextAreaWrite a program.pdf

  • 1. Question 5: Checkboxes,Radio Buttons, and JTextArea Write a program to allow the user to enter their name (using a text field), age (using a text field), gender (using radio buttons), and whether they are a student (using a check box). Include a submit button. When the user clicks submit, display a summary of the information in a text area. Solution /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package example; import javafx.application.Application; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.CheckBox; import javafx.scene.control.Label; import javafx.scene.control.RadioButton; import javafx.scene.control.TextArea; import javafx.scene.control.TextField; import javafx.scene.control.Toggle; import javafx.scene.control.ToggleGroup; import javafx.scene.layout.GridPane; import javafx.scene.layout.StackPane; import javafx.stage.Stage; /** * * @author MARIYABABU */
  • 2. public class Example extends Application { @Override public void start(Stage primaryStage) { GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(10); grid.setVgap(10); Label name = new Label("your Name:"); grid.add(name, 0, 0); TextField tname = new TextField(); grid.add(tname, 1, 0); Label age = new Label("Your age:"); grid.add(age, 0, 1); TextField tage = new TextField(); grid.add(tage, 1, 1); Label gender = new Label("Your Gender:"); grid.add(gender, 0, 2); ToggleGroup pickGender = new ToggleGroup(); RadioButton pickMale = new RadioButton("Male"); pickMale.setToggleGroup(pickGender); pickMale.setSelected(true); grid.add(pickMale,1,2); RadioButton pickFemale = new RadioButton("Female"); pickFemale.setToggleGroup(pickGender); grid.add(pickFemale,2, 2); Label std = new Label("Are you a Student?:"); grid.add(std, 0, 3); CheckBox cb1 = new CheckBox("Student"); grid.add(cb1,1,3); CheckBox cb2 = new CheckBox("Employee"); grid.add(cb2,2,3); Label summa = new Label("Summary");
  • 3. grid.add(summa, 0, 4); TextArea summary = new TextArea(); grid.add(summary, 0, 5); Button btn = new Button(); btn.setText("GET SUMMARY"); btn.setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { summary.setText( "Name :"+tname.getText()+" "+"age :"+tage.getText()+" "); //summary.appendText(name.getText()); System.out.println("I am doing Well"); } }); //final ToggleGroup group = new ToggleGroup(); pickGender.selectedToggleProperty().addListener(new ChangeListener(){ @Override public void changed(ObservableValue ov, Toggle old_toggle, Toggle new_toggle) { if (pickGender.getSelectedToggle() != null) { summary.appendText(" Gender :"+pickGender.getSelectedToggle().getUserData().toString()); } } }); grid.add(btn,1,4); Scene scene = new Scene(grid, 500, 500); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show();
  • 4. } /** * @param args the command line arguments */ public static void main(String[] args) { launch(args); } }