SlideShare a Scribd company logo
I have done it under neatbeans IDE and just added ToggleGroup for grouping radion buttons
inorder to select one at time.
package tempconverter;
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.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.control.Toggle;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class Tempconverter extends Application {
/**
* @param args the command line arguments executes project
*/
final ToggleGroup group1 = new ToggleGroup();
final ToggleGroup group2 = new ToggleGroup();
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
BorderPane pane = new BorderPane(); //the big picture
BorderPane p1 = new BorderPane();//top
BorderPane p2 = new BorderPane(); //bottom
Label temp = new Label("Enter a temperature"); //enter temp label
Label convertTemp = new Label("Converted temperature"); //converted temp label
Label input = new Label("Input Scale");//input scale label
Label output = new Label("Output Scale");//Output Scale label
TextField tempText = new TextField(); //text field to enter temp
TextField convertText = new TextField(); //output textfield for the converted temp
VBox scaleIn = new VBox(15);
VBox scaleOut = new VBox(15);
RadioButton c = new RadioButton("celcius"); //button for celcius on input side
c.setToggleGroup(group1);
RadioButton f = new RadioButton("Fahrenheit");//button for Fahrenheit on input side
f.setToggleGroup(group1);
RadioButton k = new RadioButton("kelvin");//button for kelvin on inputside
k.setToggleGroup(group1);
RadioButton c1 = new RadioButton("celcius");//button for celcius on outputside
c1.setToggleGroup(group2);
RadioButton f1 = new RadioButton("Fahrenheit"); //button for f on output side
f1.setToggleGroup(group2);
RadioButton k1 = new RadioButton("kelvin"); //button for kelvin on output side
k1.setToggleGroup(group2);
p1.setStyle("-fx-border-color:red"); //set top border pane to red
p1.setRight(tempText);
p1.setLeft(temp);
pane.setTop(p1);
pane.setBottom(p2);
p2.setLeft(convertTemp);
p2.setRight(convertText);
p2.setStyle("-fx-border-color:red");
input.setPrefWidth(100);
output.setPrefWidth(100);
c.setPrefWidth(100);
f.setPrefWidth(100);
k.setPrefWidth(100);
c1.setPrefWidth(100);
f1.setPrefWidth(100);
k1.setPrefWidth(100);
scaleIn.setStyle("-fx-border-color:red");
scaleIn.getChildren().addAll(input, c, f, k);
scaleIn.setAlignment(Pos.CENTER);
pane.setLeft(scaleIn);
TextArea error = new TextArea();
error.setEditable(false);//makes the error message unable to edit
convertText.setEditable(false);//makes output unable to edit
ScrollPane p3 = new ScrollPane(error);
p3.setStyle("-fx-border-color:red");
pane.setCenter(p3);
scaleOut.setStyle("-fx-border-color:red");
scaleOut.getChildren().addAll(output, c1, f1, k1);
scaleOut.setAlignment(Pos.CENTER);
pane.setRight(scaleOut);
//makes it so the input can only be digits.
/*tempText.setOnAction(new EventHandler() {
@Override
public void handle(ActionEvent e) {
// force the field to be numeric only
tempText.textProperty().addListener(new ChangeListener() {
@Override
public void changed(ObservableValue observable, String oldValue, String newValue) {
if (!newValue.matches("d*")) {
tempText.setText(newValue.replaceAll("[^d]", ""));
}
}
});
{
}
}
});
*/
group1.selectedToggleProperty().addListener(new ChangeListener(){
public void changed(ObservableValue ov,
Toggle old_toggle, Toggle new_toggle) {
if(group1.getSelectedToggle() == c && group2.getSelectedToggle() == c1){
String data= tempText.getText();
convertText.setText(data);
}
if(group1.getSelectedToggle() == c && group2.getSelectedToggle() == f1){
double data = Double.parseDouble(tempText.getText());
double result = data * 1.8 + 32;
convertText.setText(Double.toString(result));
}
if(group1.getSelectedToggle() == c && group2.getSelectedToggle() == k1){
double data = Double.parseDouble(tempText.getText());
double result = data + 275.15;
convertText.setText(Double.toString(result));
}
// f to other
if(group1.getSelectedToggle() == f && group2.getSelectedToggle() == f1){
String data= tempText.getText();
convertText.setText(data);
}
if(group1.getSelectedToggle() == f && group2.getSelectedToggle() == k1){
double data = Double.parseDouble(tempText.getText());
double result = (data * 459.67) * 5/9;
convertText.setText(Double.toString(result));
}
if(group1.getSelectedToggle() == f && group2.getSelectedToggle() == c1){
double data = Double.parseDouble(tempText.getText());
double result = (data - 32) * 5/9;
convertText.setText(Double.toString(result));
}
//k to other
if(group1.getSelectedToggle() == k && group2.getSelectedToggle() == k1){
String data= tempText.getText();
convertText.setText(data);
}
if(group1.getSelectedToggle() == k && group2.getSelectedToggle() == f1){
double data = Double.parseDouble(tempText.getText());
double result = (data * (9/5)) - 459.67;
convertText.setText(Double.toString(result));
}
if(group1.getSelectedToggle() == k && group2.getSelectedToggle() == c1){
double data = Double.parseDouble(tempText.getText());
double result = data -273.15;
convertText.setText(Double.toString(result));
}
}
});
group2.selectedToggleProperty().addListener(new ChangeListener(){
public void changed(ObservableValue ov,
Toggle old_toggle, Toggle new_toggle) {
if(group1.getSelectedToggle() == c && group2.getSelectedToggle() == c1){
String data= tempText.getText();
convertText.setText(data);
}
if(group1.getSelectedToggle() == c && group2.getSelectedToggle() == f1){
double data = Double.parseDouble(tempText.getText());
double result = data * 1.8 + 32;
convertText.setText(Double.toString(result));
}
if(group1.getSelectedToggle() == c && group2.getSelectedToggle() == k1){
double data = Double.parseDouble(tempText.getText());
double result = data + 275.15;
convertText.setText(Double.toString(result));
}
//f to other
if(group1.getSelectedToggle() == f && group2.getSelectedToggle() == f1){
String data= tempText.getText();
convertText.setText(data);
}
if(group1.getSelectedToggle() == f && group2.getSelectedToggle() == k1){
double data = Double.parseDouble(tempText.getText());
double result = (data * 459.67) * 5/9;
convertText.setText(Double.toString(result));
}
if(group1.getSelectedToggle() == f && group2.getSelectedToggle() == c1){
double data = Double.parseDouble(tempText.getText());
double result = (data - 32) * 5/9;
convertText.setText(Double.toString(result));
}
//k to other
if(group1.getSelectedToggle() == k && group2.getSelectedToggle() == k1){
String data= tempText.getText();
convertText.setText(data);
}
if(group1.getSelectedToggle() == k && group2.getSelectedToggle() == f1){
double data = Double.parseDouble(tempText.getText());
double result = (data * (9/5)) - 459.67;
convertText.setText(Double.toString(result));
}
if(group1.getSelectedToggle() == k && group2.getSelectedToggle() == c1){
double data = Double.parseDouble(tempText.getText());
double result = data -273.15;
convertText.setText(Double.toString(result));
}
}
});
convertText.setOnAction(e -> {
//code for the output hander
});
//event handlers for the radio buttons
c.setOnAction(e -> {
if (c.isSelected()) {
//need code in here
}
});
f.setOnAction(e -> {
if (f.isSelected()) {
//need code in here
}
});
k.setOnAction(e -> {
if (k.isSelected()) {
//need code in here
}
});
//set action handler for the radio buttons
c1.setOnAction(e -> {
if (c1.isSelected()) {
//need code in here
}
});
f1.setOnAction(e -> {
if (f1.isSelected()) {
//need code in here
}
});
k1.setOnAction(e -> {
if (k1.isSelected()) {
//need code in here
}
});
Scene scene = new Scene(pane, 400, 200);
primaryStage.setTitle("Temp Conversion");
primaryStage.setScene(scene);
primaryStage.show();
}
}
Solution
I have done it under neatbeans IDE and just added ToggleGroup for grouping radion buttons
inorder to select one at time.
package tempconverter;
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.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.control.Toggle;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class Tempconverter extends Application {
/**
* @param args the command line arguments executes project
*/
final ToggleGroup group1 = new ToggleGroup();
final ToggleGroup group2 = new ToggleGroup();
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
BorderPane pane = new BorderPane(); //the big picture
BorderPane p1 = new BorderPane();//top
BorderPane p2 = new BorderPane(); //bottom
Label temp = new Label("Enter a temperature"); //enter temp label
Label convertTemp = new Label("Converted temperature"); //converted temp label
Label input = new Label("Input Scale");//input scale label
Label output = new Label("Output Scale");//Output Scale label
TextField tempText = new TextField(); //text field to enter temp
TextField convertText = new TextField(); //output textfield for the converted temp
VBox scaleIn = new VBox(15);
VBox scaleOut = new VBox(15);
RadioButton c = new RadioButton("celcius"); //button for celcius on input side
c.setToggleGroup(group1);
RadioButton f = new RadioButton("Fahrenheit");//button for Fahrenheit on input side
f.setToggleGroup(group1);
RadioButton k = new RadioButton("kelvin");//button for kelvin on inputside
k.setToggleGroup(group1);
RadioButton c1 = new RadioButton("celcius");//button for celcius on outputside
c1.setToggleGroup(group2);
RadioButton f1 = new RadioButton("Fahrenheit"); //button for f on output side
f1.setToggleGroup(group2);
RadioButton k1 = new RadioButton("kelvin"); //button for kelvin on output side
k1.setToggleGroup(group2);
p1.setStyle("-fx-border-color:red"); //set top border pane to red
p1.setRight(tempText);
p1.setLeft(temp);
pane.setTop(p1);
pane.setBottom(p2);
p2.setLeft(convertTemp);
p2.setRight(convertText);
p2.setStyle("-fx-border-color:red");
input.setPrefWidth(100);
output.setPrefWidth(100);
c.setPrefWidth(100);
f.setPrefWidth(100);
k.setPrefWidth(100);
c1.setPrefWidth(100);
f1.setPrefWidth(100);
k1.setPrefWidth(100);
scaleIn.setStyle("-fx-border-color:red");
scaleIn.getChildren().addAll(input, c, f, k);
scaleIn.setAlignment(Pos.CENTER);
pane.setLeft(scaleIn);
TextArea error = new TextArea();
error.setEditable(false);//makes the error message unable to edit
convertText.setEditable(false);//makes output unable to edit
ScrollPane p3 = new ScrollPane(error);
p3.setStyle("-fx-border-color:red");
pane.setCenter(p3);
scaleOut.setStyle("-fx-border-color:red");
scaleOut.getChildren().addAll(output, c1, f1, k1);
scaleOut.setAlignment(Pos.CENTER);
pane.setRight(scaleOut);
//makes it so the input can only be digits.
/*tempText.setOnAction(new EventHandler() {
@Override
public void handle(ActionEvent e) {
// force the field to be numeric only
tempText.textProperty().addListener(new ChangeListener() {
@Override
public void changed(ObservableValue observable, String oldValue, String newValue) {
if (!newValue.matches("d*")) {
tempText.setText(newValue.replaceAll("[^d]", ""));
}
}
});
{
}
}
});
*/
group1.selectedToggleProperty().addListener(new ChangeListener(){
public void changed(ObservableValue ov,
Toggle old_toggle, Toggle new_toggle) {
if(group1.getSelectedToggle() == c && group2.getSelectedToggle() == c1){
String data= tempText.getText();
convertText.setText(data);
}
if(group1.getSelectedToggle() == c && group2.getSelectedToggle() == f1){
double data = Double.parseDouble(tempText.getText());
double result = data * 1.8 + 32;
convertText.setText(Double.toString(result));
}
if(group1.getSelectedToggle() == c && group2.getSelectedToggle() == k1){
double data = Double.parseDouble(tempText.getText());
double result = data + 275.15;
convertText.setText(Double.toString(result));
}
// f to other
if(group1.getSelectedToggle() == f && group2.getSelectedToggle() == f1){
String data= tempText.getText();
convertText.setText(data);
}
if(group1.getSelectedToggle() == f && group2.getSelectedToggle() == k1){
double data = Double.parseDouble(tempText.getText());
double result = (data * 459.67) * 5/9;
convertText.setText(Double.toString(result));
}
if(group1.getSelectedToggle() == f && group2.getSelectedToggle() == c1){
double data = Double.parseDouble(tempText.getText());
double result = (data - 32) * 5/9;
convertText.setText(Double.toString(result));
}
//k to other
if(group1.getSelectedToggle() == k && group2.getSelectedToggle() == k1){
String data= tempText.getText();
convertText.setText(data);
}
if(group1.getSelectedToggle() == k && group2.getSelectedToggle() == f1){
double data = Double.parseDouble(tempText.getText());
double result = (data * (9/5)) - 459.67;
convertText.setText(Double.toString(result));
}
if(group1.getSelectedToggle() == k && group2.getSelectedToggle() == c1){
double data = Double.parseDouble(tempText.getText());
double result = data -273.15;
convertText.setText(Double.toString(result));
}
}
});
group2.selectedToggleProperty().addListener(new ChangeListener(){
public void changed(ObservableValue ov,
Toggle old_toggle, Toggle new_toggle) {
if(group1.getSelectedToggle() == c && group2.getSelectedToggle() == c1){
String data= tempText.getText();
convertText.setText(data);
}
if(group1.getSelectedToggle() == c && group2.getSelectedToggle() == f1){
double data = Double.parseDouble(tempText.getText());
double result = data * 1.8 + 32;
convertText.setText(Double.toString(result));
}
if(group1.getSelectedToggle() == c && group2.getSelectedToggle() == k1){
double data = Double.parseDouble(tempText.getText());
double result = data + 275.15;
convertText.setText(Double.toString(result));
}
//f to other
if(group1.getSelectedToggle() == f && group2.getSelectedToggle() == f1){
String data= tempText.getText();
convertText.setText(data);
}
if(group1.getSelectedToggle() == f && group2.getSelectedToggle() == k1){
double data = Double.parseDouble(tempText.getText());
double result = (data * 459.67) * 5/9;
convertText.setText(Double.toString(result));
}
if(group1.getSelectedToggle() == f && group2.getSelectedToggle() == c1){
double data = Double.parseDouble(tempText.getText());
double result = (data - 32) * 5/9;
convertText.setText(Double.toString(result));
}
//k to other
if(group1.getSelectedToggle() == k && group2.getSelectedToggle() == k1){
String data= tempText.getText();
convertText.setText(data);
}
if(group1.getSelectedToggle() == k && group2.getSelectedToggle() == f1){
double data = Double.parseDouble(tempText.getText());
double result = (data * (9/5)) - 459.67;
convertText.setText(Double.toString(result));
}
if(group1.getSelectedToggle() == k && group2.getSelectedToggle() == c1){
double data = Double.parseDouble(tempText.getText());
double result = data -273.15;
convertText.setText(Double.toString(result));
}
}
});
convertText.setOnAction(e -> {
//code for the output hander
});
//event handlers for the radio buttons
c.setOnAction(e -> {
if (c.isSelected()) {
//need code in here
}
});
f.setOnAction(e -> {
if (f.isSelected()) {
//need code in here
}
});
k.setOnAction(e -> {
if (k.isSelected()) {
//need code in here
}
});
//set action handler for the radio buttons
c1.setOnAction(e -> {
if (c1.isSelected()) {
//need code in here
}
});
f1.setOnAction(e -> {
if (f1.isSelected()) {
//need code in here
}
});
k1.setOnAction(e -> {
if (k1.isSelected()) {
//need code in here
}
});
Scene scene = new Scene(pane, 400, 200);
primaryStage.setTitle("Temp Conversion");
primaryStage.setScene(scene);
primaryStage.show();
}
}

More Related Content

Similar to I have done it under neatbeans IDE and just added ToggleGroup for gr.pdf

package net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdfpackage net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdf
sudhirchourasia86
 
Please help!!I wanted to know how to add a high score to this prog.pdf
Please help!!I wanted to know how to add a high score to this prog.pdfPlease help!!I wanted to know how to add a high score to this prog.pdf
Please help!!I wanted to know how to add a high score to this prog.pdf
JUSTSTYLISH3B2MOHALI
 
Flink Batch Processing and Iterations
Flink Batch Processing and IterationsFlink Batch Processing and Iterations
Flink Batch Processing and Iterations
Sameer Wadkar
 
Write a GUI application to simulate writing out a check. The value o.pdf
Write a GUI application to simulate writing out a check. The value o.pdfWrite a GUI application to simulate writing out a check. The value o.pdf
Write a GUI application to simulate writing out a check. The value o.pdf
fathimaoptical
 
In Java Write a GUI application to simulate writing out a check. The.pdf
In Java Write a GUI application to simulate writing out a check. The.pdfIn Java Write a GUI application to simulate writing out a check. The.pdf
In Java Write a GUI application to simulate writing out a check. The.pdf
flashfashioncasualwe
 
C# Application program UNIT III
C# Application program UNIT IIIC# Application program UNIT III
C# Application program UNIT IIIMinu Rajasekaran
 
Binary patching for fun and profit @ JUG.ru, 25.02.2012
Binary patching for fun and profit @ JUG.ru, 25.02.2012Binary patching for fun and profit @ JUG.ru, 25.02.2012
Binary patching for fun and profit @ JUG.ru, 25.02.2012Anton Arhipov
 
Clustering your Application with Hazelcast
Clustering your Application with HazelcastClustering your Application with Hazelcast
Clustering your Application with Hazelcast
Hazelcast
 
Test beautycleanness
Test beautycleannessTest beautycleanness
Test beautycleanness
bergel
 
Bindings: the zen of montage
Bindings: the zen of montageBindings: the zen of montage
Bindings: the zen of montageKris Kowal
 
Ejemplo radio
Ejemplo radioEjemplo radio
Ejemplo radio
lupe ga
 
Higher Order Components and Render Props
Higher Order Components and Render PropsHigher Order Components and Render Props
Higher Order Components and Render Props
Nitish Phanse
 
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
 
Write a Java class to represent a temperature. The class has a single.pdf
Write a Java class to represent a temperature. The class has a single.pdfWrite a Java class to represent a temperature. The class has a single.pdf
Write a Java class to represent a temperature. The class has a single.pdf
footwearpark
 
Monadic Comprehensions and Functional Composition with Query Expressions
Monadic Comprehensions and Functional Composition with Query ExpressionsMonadic Comprehensions and Functional Composition with Query Expressions
Monadic Comprehensions and Functional Composition with Query Expressions
Chris Eargle
 
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docxCodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
mary772
 
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docxCodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
mccormicknadine86
 
Async JavaScript in ES7
Async JavaScript in ES7Async JavaScript in ES7
Async JavaScript in ES7
Mike North
 
React hooks
React hooksReact hooks
React hooks
Assaf Gannon
 

Similar to I have done it under neatbeans IDE and just added ToggleGroup for gr.pdf (20)

package net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdfpackage net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdf
 
Please help!!I wanted to know how to add a high score to this prog.pdf
Please help!!I wanted to know how to add a high score to this prog.pdfPlease help!!I wanted to know how to add a high score to this prog.pdf
Please help!!I wanted to know how to add a high score to this prog.pdf
 
Flink Batch Processing and Iterations
Flink Batch Processing and IterationsFlink Batch Processing and Iterations
Flink Batch Processing and Iterations
 
Write a GUI application to simulate writing out a check. The value o.pdf
Write a GUI application to simulate writing out a check. The value o.pdfWrite a GUI application to simulate writing out a check. The value o.pdf
Write a GUI application to simulate writing out a check. The value o.pdf
 
In Java Write a GUI application to simulate writing out a check. The.pdf
In Java Write a GUI application to simulate writing out a check. The.pdfIn Java Write a GUI application to simulate writing out a check. The.pdf
In Java Write a GUI application to simulate writing out a check. The.pdf
 
C# Application program UNIT III
C# Application program UNIT IIIC# Application program UNIT III
C# Application program UNIT III
 
Binary patching for fun and profit @ JUG.ru, 25.02.2012
Binary patching for fun and profit @ JUG.ru, 25.02.2012Binary patching for fun and profit @ JUG.ru, 25.02.2012
Binary patching for fun and profit @ JUG.ru, 25.02.2012
 
Clustering your Application with Hazelcast
Clustering your Application with HazelcastClustering your Application with Hazelcast
Clustering your Application with Hazelcast
 
Test beautycleanness
Test beautycleannessTest beautycleanness
Test beautycleanness
 
Bindings: the zen of montage
Bindings: the zen of montageBindings: the zen of montage
Bindings: the zen of montage
 
Ejemplo radio
Ejemplo radioEjemplo radio
Ejemplo radio
 
Higher Order Components and Render Props
Higher Order Components and Render PropsHigher Order Components and Render Props
Higher Order Components and Render Props
 
Swing
SwingSwing
Swing
 
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
 
Write a Java class to represent a temperature. The class has a single.pdf
Write a Java class to represent a temperature. The class has a single.pdfWrite a Java class to represent a temperature. The class has a single.pdf
Write a Java class to represent a temperature. The class has a single.pdf
 
Monadic Comprehensions and Functional Composition with Query Expressions
Monadic Comprehensions and Functional Composition with Query ExpressionsMonadic Comprehensions and Functional Composition with Query Expressions
Monadic Comprehensions and Functional Composition with Query Expressions
 
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docxCodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
 
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docxCodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
 
Async JavaScript in ES7
Async JavaScript in ES7Async JavaScript in ES7
Async JavaScript in ES7
 
React hooks
React hooksReact hooks
React hooks
 

More from annaimobiles

The equation you should use is just a variation of the PV formula.pdf
 The equation you should use is just a variation of the PV formula.pdf The equation you should use is just a variation of the PV formula.pdf
The equation you should use is just a variation of the PV formula.pdf
annaimobiles
 
True short double stranded mRNA are involved in initiating the inte.pdf
  True short double stranded mRNA are involved in initiating the inte.pdf  True short double stranded mRNA are involved in initiating the inte.pdf
True short double stranded mRNA are involved in initiating the inte.pdf
annaimobiles
 
Yes, it would react similarly, since boric oxide .pdf
                     Yes, it would react similarly, since boric oxide .pdf                     Yes, it would react similarly, since boric oxide .pdf
Yes, it would react similarly, since boric oxide .pdf
annaimobiles
 
spontaneous .pdf
                     spontaneous                                      .pdf                     spontaneous                                      .pdf
spontaneous .pdf
annaimobiles
 
sol Solution A,D,E Crenation Solution B Hemol.pdf
                     sol  Solution A,D,E Crenation Solution B Hemol.pdf                     sol  Solution A,D,E Crenation Solution B Hemol.pdf
sol Solution A,D,E Crenation Solution B Hemol.pdf
annaimobiles
 
please post the figure.... .pdf
                     please post the figure....                       .pdf                     please post the figure....                       .pdf
please post the figure.... .pdf
annaimobiles
 
Intermediate species means species that have 2 ch.pdf
                     Intermediate species means species that have 2 ch.pdf                     Intermediate species means species that have 2 ch.pdf
Intermediate species means species that have 2 ch.pdf
annaimobiles
 
In primitive cells atoms are present at the corne.pdf
                     In primitive cells atoms are present at the corne.pdf                     In primitive cells atoms are present at the corne.pdf
In primitive cells atoms are present at the corne.pdf
annaimobiles
 
Hg2+ is more water soluble, methyl mercury HgCH3+.pdf
                     Hg2+ is more water soluble, methyl mercury HgCH3+.pdf                     Hg2+ is more water soluble, methyl mercury HgCH3+.pdf
Hg2+ is more water soluble, methyl mercury HgCH3+.pdf
annaimobiles
 
HCl is a polar-covalent compound and also Acetoni.pdf
                     HCl is a polar-covalent compound and also Acetoni.pdf                     HCl is a polar-covalent compound and also Acetoni.pdf
HCl is a polar-covalent compound and also Acetoni.pdf
annaimobiles
 
for a compound to be soluble in water 1. it shou.pdf
                     for a compound to be soluble in water  1. it shou.pdf                     for a compound to be soluble in water  1. it shou.pdf
for a compound to be soluble in water 1. it shou.pdf
annaimobiles
 
e) II and III have the loest, equal stability .pdf
                     e) II and III have the loest, equal stability .pdf                     e) II and III have the loest, equal stability .pdf
e) II and III have the loest, equal stability .pdf
annaimobiles
 
wait doingSolutionwait doing.pdf
wait doingSolutionwait doing.pdfwait doingSolutionwait doing.pdf
wait doingSolutionwait doing.pdf
annaimobiles
 
TRUE The Reynolds number of falling 2.5 micrometer flyash particles .pdf
TRUE The Reynolds number of falling 2.5 micrometer flyash particles .pdfTRUE The Reynolds number of falling 2.5 micrometer flyash particles .pdf
TRUE The Reynolds number of falling 2.5 micrometer flyash particles .pdf
annaimobiles
 
the electron rich molecule is a central Xe with 4 F singlebonded.pdf
the electron rich molecule is a central Xe with 4 F singlebonded.pdfthe electron rich molecule is a central Xe with 4 F singlebonded.pdf
the electron rich molecule is a central Xe with 4 F singlebonded.pdf
annaimobiles
 
The given formulae themselves are explicit. Explicit means direct i..pdf
The given formulae themselves are explicit. Explicit means direct i..pdfThe given formulae themselves are explicit. Explicit means direct i..pdf
The given formulae themselves are explicit. Explicit means direct i..pdf
annaimobiles
 
The answer is Meiosis, It occurs in human body at reporductive organ.pdf
The answer is Meiosis, It occurs in human body at reporductive organ.pdfThe answer is Meiosis, It occurs in human body at reporductive organ.pdf
The answer is Meiosis, It occurs in human body at reporductive organ.pdf
annaimobiles
 
Structure of HemoglobinHemoglobin is a chromo protein and is found.pdf
Structure of HemoglobinHemoglobin is a chromo protein and is found.pdfStructure of HemoglobinHemoglobin is a chromo protein and is found.pdf
Structure of HemoglobinHemoglobin is a chromo protein and is found.pdf
annaimobiles
 
SolutionSelection Sort after two iterations1 14 8 9 5 16 2 1.pdf
SolutionSelection Sort after two iterations1 14 8 9 5 16 2 1.pdfSolutionSelection Sort after two iterations1 14 8 9 5 16 2 1.pdf
SolutionSelection Sort after two iterations1 14 8 9 5 16 2 1.pdf
annaimobiles
 
Starch agar consists of starch. The secretion of amylase enzyme by s.pdf
Starch agar consists of starch. The secretion of amylase enzyme by s.pdfStarch agar consists of starch. The secretion of amylase enzyme by s.pdf
Starch agar consists of starch. The secretion of amylase enzyme by s.pdf
annaimobiles
 

More from annaimobiles (20)

The equation you should use is just a variation of the PV formula.pdf
 The equation you should use is just a variation of the PV formula.pdf The equation you should use is just a variation of the PV formula.pdf
The equation you should use is just a variation of the PV formula.pdf
 
True short double stranded mRNA are involved in initiating the inte.pdf
  True short double stranded mRNA are involved in initiating the inte.pdf  True short double stranded mRNA are involved in initiating the inte.pdf
True short double stranded mRNA are involved in initiating the inte.pdf
 
Yes, it would react similarly, since boric oxide .pdf
                     Yes, it would react similarly, since boric oxide .pdf                     Yes, it would react similarly, since boric oxide .pdf
Yes, it would react similarly, since boric oxide .pdf
 
spontaneous .pdf
                     spontaneous                                      .pdf                     spontaneous                                      .pdf
spontaneous .pdf
 
sol Solution A,D,E Crenation Solution B Hemol.pdf
                     sol  Solution A,D,E Crenation Solution B Hemol.pdf                     sol  Solution A,D,E Crenation Solution B Hemol.pdf
sol Solution A,D,E Crenation Solution B Hemol.pdf
 
please post the figure.... .pdf
                     please post the figure....                       .pdf                     please post the figure....                       .pdf
please post the figure.... .pdf
 
Intermediate species means species that have 2 ch.pdf
                     Intermediate species means species that have 2 ch.pdf                     Intermediate species means species that have 2 ch.pdf
Intermediate species means species that have 2 ch.pdf
 
In primitive cells atoms are present at the corne.pdf
                     In primitive cells atoms are present at the corne.pdf                     In primitive cells atoms are present at the corne.pdf
In primitive cells atoms are present at the corne.pdf
 
Hg2+ is more water soluble, methyl mercury HgCH3+.pdf
                     Hg2+ is more water soluble, methyl mercury HgCH3+.pdf                     Hg2+ is more water soluble, methyl mercury HgCH3+.pdf
Hg2+ is more water soluble, methyl mercury HgCH3+.pdf
 
HCl is a polar-covalent compound and also Acetoni.pdf
                     HCl is a polar-covalent compound and also Acetoni.pdf                     HCl is a polar-covalent compound and also Acetoni.pdf
HCl is a polar-covalent compound and also Acetoni.pdf
 
for a compound to be soluble in water 1. it shou.pdf
                     for a compound to be soluble in water  1. it shou.pdf                     for a compound to be soluble in water  1. it shou.pdf
for a compound to be soluble in water 1. it shou.pdf
 
e) II and III have the loest, equal stability .pdf
                     e) II and III have the loest, equal stability .pdf                     e) II and III have the loest, equal stability .pdf
e) II and III have the loest, equal stability .pdf
 
wait doingSolutionwait doing.pdf
wait doingSolutionwait doing.pdfwait doingSolutionwait doing.pdf
wait doingSolutionwait doing.pdf
 
TRUE The Reynolds number of falling 2.5 micrometer flyash particles .pdf
TRUE The Reynolds number of falling 2.5 micrometer flyash particles .pdfTRUE The Reynolds number of falling 2.5 micrometer flyash particles .pdf
TRUE The Reynolds number of falling 2.5 micrometer flyash particles .pdf
 
the electron rich molecule is a central Xe with 4 F singlebonded.pdf
the electron rich molecule is a central Xe with 4 F singlebonded.pdfthe electron rich molecule is a central Xe with 4 F singlebonded.pdf
the electron rich molecule is a central Xe with 4 F singlebonded.pdf
 
The given formulae themselves are explicit. Explicit means direct i..pdf
The given formulae themselves are explicit. Explicit means direct i..pdfThe given formulae themselves are explicit. Explicit means direct i..pdf
The given formulae themselves are explicit. Explicit means direct i..pdf
 
The answer is Meiosis, It occurs in human body at reporductive organ.pdf
The answer is Meiosis, It occurs in human body at reporductive organ.pdfThe answer is Meiosis, It occurs in human body at reporductive organ.pdf
The answer is Meiosis, It occurs in human body at reporductive organ.pdf
 
Structure of HemoglobinHemoglobin is a chromo protein and is found.pdf
Structure of HemoglobinHemoglobin is a chromo protein and is found.pdfStructure of HemoglobinHemoglobin is a chromo protein and is found.pdf
Structure of HemoglobinHemoglobin is a chromo protein and is found.pdf
 
SolutionSelection Sort after two iterations1 14 8 9 5 16 2 1.pdf
SolutionSelection Sort after two iterations1 14 8 9 5 16 2 1.pdfSolutionSelection Sort after two iterations1 14 8 9 5 16 2 1.pdf
SolutionSelection Sort after two iterations1 14 8 9 5 16 2 1.pdf
 
Starch agar consists of starch. The secretion of amylase enzyme by s.pdf
Starch agar consists of starch. The secretion of amylase enzyme by s.pdfStarch agar consists of starch. The secretion of amylase enzyme by s.pdf
Starch agar consists of starch. The secretion of amylase enzyme by s.pdf
 

Recently uploaded

STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
gb193092
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 

Recently uploaded (20)

STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 

I have done it under neatbeans IDE and just added ToggleGroup for gr.pdf

  • 1. I have done it under neatbeans IDE and just added ToggleGroup for grouping radion buttons inorder to select one at time. package tempconverter; 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.Label; import javafx.scene.control.RadioButton; import javafx.scene.control.ScrollPane; import javafx.scene.control.TextArea; import javafx.scene.control.TextField; import javafx.scene.control.Toggle; import javafx.scene.control.ToggleGroup; import javafx.scene.layout.BorderPane; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.stage.Stage; public class Tempconverter extends Application { /** * @param args the command line arguments executes project */ final ToggleGroup group1 = new ToggleGroup(); final ToggleGroup group2 = new ToggleGroup(); public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) throws Exception { BorderPane pane = new BorderPane(); //the big picture BorderPane p1 = new BorderPane();//top
  • 2. BorderPane p2 = new BorderPane(); //bottom Label temp = new Label("Enter a temperature"); //enter temp label Label convertTemp = new Label("Converted temperature"); //converted temp label Label input = new Label("Input Scale");//input scale label Label output = new Label("Output Scale");//Output Scale label TextField tempText = new TextField(); //text field to enter temp TextField convertText = new TextField(); //output textfield for the converted temp VBox scaleIn = new VBox(15); VBox scaleOut = new VBox(15); RadioButton c = new RadioButton("celcius"); //button for celcius on input side c.setToggleGroup(group1); RadioButton f = new RadioButton("Fahrenheit");//button for Fahrenheit on input side f.setToggleGroup(group1); RadioButton k = new RadioButton("kelvin");//button for kelvin on inputside k.setToggleGroup(group1); RadioButton c1 = new RadioButton("celcius");//button for celcius on outputside c1.setToggleGroup(group2); RadioButton f1 = new RadioButton("Fahrenheit"); //button for f on output side f1.setToggleGroup(group2); RadioButton k1 = new RadioButton("kelvin"); //button for kelvin on output side k1.setToggleGroup(group2); p1.setStyle("-fx-border-color:red"); //set top border pane to red p1.setRight(tempText); p1.setLeft(temp); pane.setTop(p1); pane.setBottom(p2); p2.setLeft(convertTemp); p2.setRight(convertText); p2.setStyle("-fx-border-color:red"); input.setPrefWidth(100); output.setPrefWidth(100); c.setPrefWidth(100); f.setPrefWidth(100); k.setPrefWidth(100);
  • 3. c1.setPrefWidth(100); f1.setPrefWidth(100); k1.setPrefWidth(100); scaleIn.setStyle("-fx-border-color:red"); scaleIn.getChildren().addAll(input, c, f, k); scaleIn.setAlignment(Pos.CENTER); pane.setLeft(scaleIn); TextArea error = new TextArea(); error.setEditable(false);//makes the error message unable to edit convertText.setEditable(false);//makes output unable to edit ScrollPane p3 = new ScrollPane(error); p3.setStyle("-fx-border-color:red"); pane.setCenter(p3); scaleOut.setStyle("-fx-border-color:red"); scaleOut.getChildren().addAll(output, c1, f1, k1); scaleOut.setAlignment(Pos.CENTER); pane.setRight(scaleOut); //makes it so the input can only be digits. /*tempText.setOnAction(new EventHandler() { @Override public void handle(ActionEvent e) { // force the field to be numeric only tempText.textProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, String oldValue, String newValue) { if (!newValue.matches("d*")) { tempText.setText(newValue.replaceAll("[^d]", "")); } } }); { } } }); */ group1.selectedToggleProperty().addListener(new ChangeListener(){
  • 4. public void changed(ObservableValue ov, Toggle old_toggle, Toggle new_toggle) { if(group1.getSelectedToggle() == c && group2.getSelectedToggle() == c1){ String data= tempText.getText(); convertText.setText(data); } if(group1.getSelectedToggle() == c && group2.getSelectedToggle() == f1){ double data = Double.parseDouble(tempText.getText()); double result = data * 1.8 + 32; convertText.setText(Double.toString(result)); } if(group1.getSelectedToggle() == c && group2.getSelectedToggle() == k1){ double data = Double.parseDouble(tempText.getText()); double result = data + 275.15; convertText.setText(Double.toString(result)); } // f to other if(group1.getSelectedToggle() == f && group2.getSelectedToggle() == f1){ String data= tempText.getText(); convertText.setText(data); } if(group1.getSelectedToggle() == f && group2.getSelectedToggle() == k1){ double data = Double.parseDouble(tempText.getText()); double result = (data * 459.67) * 5/9; convertText.setText(Double.toString(result)); } if(group1.getSelectedToggle() == f && group2.getSelectedToggle() == c1){ double data = Double.parseDouble(tempText.getText()); double result = (data - 32) * 5/9; convertText.setText(Double.toString(result)); } //k to other if(group1.getSelectedToggle() == k && group2.getSelectedToggle() == k1){ String data= tempText.getText(); convertText.setText(data); }
  • 5. if(group1.getSelectedToggle() == k && group2.getSelectedToggle() == f1){ double data = Double.parseDouble(tempText.getText()); double result = (data * (9/5)) - 459.67; convertText.setText(Double.toString(result)); } if(group1.getSelectedToggle() == k && group2.getSelectedToggle() == c1){ double data = Double.parseDouble(tempText.getText()); double result = data -273.15; convertText.setText(Double.toString(result)); } } }); group2.selectedToggleProperty().addListener(new ChangeListener(){ public void changed(ObservableValue ov, Toggle old_toggle, Toggle new_toggle) { if(group1.getSelectedToggle() == c && group2.getSelectedToggle() == c1){ String data= tempText.getText(); convertText.setText(data); } if(group1.getSelectedToggle() == c && group2.getSelectedToggle() == f1){ double data = Double.parseDouble(tempText.getText()); double result = data * 1.8 + 32; convertText.setText(Double.toString(result)); } if(group1.getSelectedToggle() == c && group2.getSelectedToggle() == k1){ double data = Double.parseDouble(tempText.getText()); double result = data + 275.15; convertText.setText(Double.toString(result)); } //f to other if(group1.getSelectedToggle() == f && group2.getSelectedToggle() == f1){ String data= tempText.getText(); convertText.setText(data); }
  • 6. if(group1.getSelectedToggle() == f && group2.getSelectedToggle() == k1){ double data = Double.parseDouble(tempText.getText()); double result = (data * 459.67) * 5/9; convertText.setText(Double.toString(result)); } if(group1.getSelectedToggle() == f && group2.getSelectedToggle() == c1){ double data = Double.parseDouble(tempText.getText()); double result = (data - 32) * 5/9; convertText.setText(Double.toString(result)); } //k to other if(group1.getSelectedToggle() == k && group2.getSelectedToggle() == k1){ String data= tempText.getText(); convertText.setText(data); } if(group1.getSelectedToggle() == k && group2.getSelectedToggle() == f1){ double data = Double.parseDouble(tempText.getText()); double result = (data * (9/5)) - 459.67; convertText.setText(Double.toString(result)); } if(group1.getSelectedToggle() == k && group2.getSelectedToggle() == c1){ double data = Double.parseDouble(tempText.getText()); double result = data -273.15; convertText.setText(Double.toString(result)); } } }); convertText.setOnAction(e -> { //code for the output hander }); //event handlers for the radio buttons c.setOnAction(e -> { if (c.isSelected()) {
  • 7. //need code in here } }); f.setOnAction(e -> { if (f.isSelected()) { //need code in here } }); k.setOnAction(e -> { if (k.isSelected()) { //need code in here } }); //set action handler for the radio buttons c1.setOnAction(e -> { if (c1.isSelected()) { //need code in here } }); f1.setOnAction(e -> { if (f1.isSelected()) { //need code in here } }); k1.setOnAction(e -> { if (k1.isSelected()) { //need code in here } }); Scene scene = new Scene(pane, 400, 200); primaryStage.setTitle("Temp Conversion"); primaryStage.setScene(scene); primaryStage.show(); } }
  • 8. Solution I have done it under neatbeans IDE and just added ToggleGroup for grouping radion buttons inorder to select one at time. package tempconverter; 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.Label; import javafx.scene.control.RadioButton; import javafx.scene.control.ScrollPane; import javafx.scene.control.TextArea; import javafx.scene.control.TextField; import javafx.scene.control.Toggle; import javafx.scene.control.ToggleGroup; import javafx.scene.layout.BorderPane; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.stage.Stage; public class Tempconverter extends Application { /** * @param args the command line arguments executes project */ final ToggleGroup group1 = new ToggleGroup(); final ToggleGroup group2 = new ToggleGroup(); public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) throws Exception { BorderPane pane = new BorderPane(); //the big picture
  • 9. BorderPane p1 = new BorderPane();//top BorderPane p2 = new BorderPane(); //bottom Label temp = new Label("Enter a temperature"); //enter temp label Label convertTemp = new Label("Converted temperature"); //converted temp label Label input = new Label("Input Scale");//input scale label Label output = new Label("Output Scale");//Output Scale label TextField tempText = new TextField(); //text field to enter temp TextField convertText = new TextField(); //output textfield for the converted temp VBox scaleIn = new VBox(15); VBox scaleOut = new VBox(15); RadioButton c = new RadioButton("celcius"); //button for celcius on input side c.setToggleGroup(group1); RadioButton f = new RadioButton("Fahrenheit");//button for Fahrenheit on input side f.setToggleGroup(group1); RadioButton k = new RadioButton("kelvin");//button for kelvin on inputside k.setToggleGroup(group1); RadioButton c1 = new RadioButton("celcius");//button for celcius on outputside c1.setToggleGroup(group2); RadioButton f1 = new RadioButton("Fahrenheit"); //button for f on output side f1.setToggleGroup(group2); RadioButton k1 = new RadioButton("kelvin"); //button for kelvin on output side k1.setToggleGroup(group2); p1.setStyle("-fx-border-color:red"); //set top border pane to red p1.setRight(tempText); p1.setLeft(temp); pane.setTop(p1); pane.setBottom(p2); p2.setLeft(convertTemp); p2.setRight(convertText); p2.setStyle("-fx-border-color:red"); input.setPrefWidth(100); output.setPrefWidth(100); c.setPrefWidth(100); f.setPrefWidth(100);
  • 10. k.setPrefWidth(100); c1.setPrefWidth(100); f1.setPrefWidth(100); k1.setPrefWidth(100); scaleIn.setStyle("-fx-border-color:red"); scaleIn.getChildren().addAll(input, c, f, k); scaleIn.setAlignment(Pos.CENTER); pane.setLeft(scaleIn); TextArea error = new TextArea(); error.setEditable(false);//makes the error message unable to edit convertText.setEditable(false);//makes output unable to edit ScrollPane p3 = new ScrollPane(error); p3.setStyle("-fx-border-color:red"); pane.setCenter(p3); scaleOut.setStyle("-fx-border-color:red"); scaleOut.getChildren().addAll(output, c1, f1, k1); scaleOut.setAlignment(Pos.CENTER); pane.setRight(scaleOut); //makes it so the input can only be digits. /*tempText.setOnAction(new EventHandler() { @Override public void handle(ActionEvent e) { // force the field to be numeric only tempText.textProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, String oldValue, String newValue) { if (!newValue.matches("d*")) { tempText.setText(newValue.replaceAll("[^d]", "")); } } }); { } } }); */
  • 11. group1.selectedToggleProperty().addListener(new ChangeListener(){ public void changed(ObservableValue ov, Toggle old_toggle, Toggle new_toggle) { if(group1.getSelectedToggle() == c && group2.getSelectedToggle() == c1){ String data= tempText.getText(); convertText.setText(data); } if(group1.getSelectedToggle() == c && group2.getSelectedToggle() == f1){ double data = Double.parseDouble(tempText.getText()); double result = data * 1.8 + 32; convertText.setText(Double.toString(result)); } if(group1.getSelectedToggle() == c && group2.getSelectedToggle() == k1){ double data = Double.parseDouble(tempText.getText()); double result = data + 275.15; convertText.setText(Double.toString(result)); } // f to other if(group1.getSelectedToggle() == f && group2.getSelectedToggle() == f1){ String data= tempText.getText(); convertText.setText(data); } if(group1.getSelectedToggle() == f && group2.getSelectedToggle() == k1){ double data = Double.parseDouble(tempText.getText()); double result = (data * 459.67) * 5/9; convertText.setText(Double.toString(result)); } if(group1.getSelectedToggle() == f && group2.getSelectedToggle() == c1){ double data = Double.parseDouble(tempText.getText()); double result = (data - 32) * 5/9; convertText.setText(Double.toString(result)); } //k to other if(group1.getSelectedToggle() == k && group2.getSelectedToggle() == k1){ String data= tempText.getText(); convertText.setText(data);
  • 12. } if(group1.getSelectedToggle() == k && group2.getSelectedToggle() == f1){ double data = Double.parseDouble(tempText.getText()); double result = (data * (9/5)) - 459.67; convertText.setText(Double.toString(result)); } if(group1.getSelectedToggle() == k && group2.getSelectedToggle() == c1){ double data = Double.parseDouble(tempText.getText()); double result = data -273.15; convertText.setText(Double.toString(result)); } } }); group2.selectedToggleProperty().addListener(new ChangeListener(){ public void changed(ObservableValue ov, Toggle old_toggle, Toggle new_toggle) { if(group1.getSelectedToggle() == c && group2.getSelectedToggle() == c1){ String data= tempText.getText(); convertText.setText(data); } if(group1.getSelectedToggle() == c && group2.getSelectedToggle() == f1){ double data = Double.parseDouble(tempText.getText()); double result = data * 1.8 + 32; convertText.setText(Double.toString(result)); } if(group1.getSelectedToggle() == c && group2.getSelectedToggle() == k1){ double data = Double.parseDouble(tempText.getText()); double result = data + 275.15; convertText.setText(Double.toString(result)); } //f to other if(group1.getSelectedToggle() == f && group2.getSelectedToggle() == f1){ String data= tempText.getText(); convertText.setText(data);
  • 13. } if(group1.getSelectedToggle() == f && group2.getSelectedToggle() == k1){ double data = Double.parseDouble(tempText.getText()); double result = (data * 459.67) * 5/9; convertText.setText(Double.toString(result)); } if(group1.getSelectedToggle() == f && group2.getSelectedToggle() == c1){ double data = Double.parseDouble(tempText.getText()); double result = (data - 32) * 5/9; convertText.setText(Double.toString(result)); } //k to other if(group1.getSelectedToggle() == k && group2.getSelectedToggle() == k1){ String data= tempText.getText(); convertText.setText(data); } if(group1.getSelectedToggle() == k && group2.getSelectedToggle() == f1){ double data = Double.parseDouble(tempText.getText()); double result = (data * (9/5)) - 459.67; convertText.setText(Double.toString(result)); } if(group1.getSelectedToggle() == k && group2.getSelectedToggle() == c1){ double data = Double.parseDouble(tempText.getText()); double result = data -273.15; convertText.setText(Double.toString(result)); } } }); convertText.setOnAction(e -> { //code for the output hander }); //event handlers for the radio buttons c.setOnAction(e -> {
  • 14. if (c.isSelected()) { //need code in here } }); f.setOnAction(e -> { if (f.isSelected()) { //need code in here } }); k.setOnAction(e -> { if (k.isSelected()) { //need code in here } }); //set action handler for the radio buttons c1.setOnAction(e -> { if (c1.isSelected()) { //need code in here } }); f1.setOnAction(e -> { if (f1.isSelected()) { //need code in here } }); k1.setOnAction(e -> { if (k1.isSelected()) { //need code in here } }); Scene scene = new Scene(pane, 400, 200); primaryStage.setTitle("Temp Conversion"); primaryStage.setScene(scene); primaryStage.show(); } }