Tuesday, August 11, 2020

#111 Design the GUI interface as shown in the picture below

Design the GUI interface as shown in the picture below - Computer Science

ChemistryExplain daily providing Q&A content “#111 Design the GUI interface as shown in the picture below" in Computer science, Ba computer science, Berkeley computer science, Computer science associate degree jobs.
Chemistryexplain “#111 Design the GUI interface as shown in the picture below in Computer science, Ba computer science, Berkeley computer science, Computer science associate degree jobs
Get the Free Online Chemistry Q&A Questions And Answers with explain. To crack any examinations and Interview tests these Chemistry Questions And Answers are very useful. Here we have uploaded the Free Online Chemistry Questions. Here we are also given the all chemistry topic.
 ChemistryExplain team has covered all Topics related to inorganic, organic, physical chemistry, and others So, Prepare these Chemistry Questions and Answers with Explanation Pdf.
For More Chegg Questions

Free Chegg Question

Design: design the GUI interface as shown in the picture below.
Please pay attention to the widths of the columns, width of the controls, control alignment, gaps between the controls, padding around the entire interface, and etc.
Hints: set the size of the scene to be 450px by 450px.

2. Functionality : add the functionality as follows:
  • when one of the command buttons (Add, Subtract, Multiple, or Divide) is clicked, retrieve the values from the Value 1 and Value 2 text fields, and convert the retrieved values to the double type. Then, calculate and display the result as a row in the below listView control using the following format
the ddd of aaa and bbb is ccc
where aaa is the value retrieved from Value 1 text field
where bbb is the value retrieved from Value 2 text field
where ccc is the result of the calculation
where ddd is the action taken (Add, Subtract, Multiple, or Divide)
  • when clicking on "Remove from list" button, the selected list must be deleted and disap- pear from the listView as a result.
3. Grading: the mark will be partially based on how close your interface will match the interface below, in addition to the functionality. Comments are required.
Note: errors (the code does not run) in the submitted code will result in a 50% penalty
4. Submission:
a. a full working project (.zip file)
b. a doc file containing all java code from all files plus at least two images of the running application (both with and without performed calculations displayed in listView).
Chemistryexplain “#111 Design the GUI interface as shown in the picture below in Computer science, Ba computer science, Berkeley computer science, Computer science associate degree jobs

For More Chemistry Notes and Helpful Content Subscribe Our YouTube Chanel - Chemistry Explain  

Free Chegg Answer

 Calculator5.java:

package calculator5;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Calculator5 extends Application {
    @Override
    public void start(Stage stage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));    //load fxml 
        Scene scene = new Scene(root);
        stage.setTitle("A5.fxml");
        stage.setScene(scene);
        stage.show();
    }
    public static void main(String[] args) {
        launch(args);
    }
}
FXMLDocument.fxml:
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane id="AnchorPane" prefHeight="200" prefWidth="320" xmlns:fx="http://javafx.com/fxml/1" fx:controller="calculator5.FXMLDocumentController">
    <children>
      <Label layoutX="14.0" layoutY="56.0" text="Value 1:" />
      <TextField fx:id="txtValue1" accessibleText="Hello" layoutX="67.0" layoutY="51.0" prefHeight="27.0" prefWidth="194.0" />
      <Label layoutX="14.0" layoutY="102.0" text="Value 2:" />
      <TextField fx:id="txtValue2" layoutX="67.0" layoutY="97.0" prefHeight="27.0" prefWidth="194.0" />
      <Button fx:id="btnMultiply" layoutX="14.0" layoutY="143.0" mnemonicParsing="false" text="Multiply" textAlignment="CENTER" onAction="#MultiplyButtonPressed"/>
      <Button fx:id="btnDivide" layoutX="85.0" layoutY="143.0" mnemonicParsing="false" text="Divide" textAlignment="CENTER" onAction="#DivideButtonPressed"/>
      <Button fx:id="btnAdd" layoutX="147.0" layoutY="143.0" mnemonicParsing="false" text="Add" textAlignment="CENTER" onAction="#AddButtonPressed"/>
      <Button fx:id="btnSubtract" layoutX="199.0" layoutY="143.0" mnemonicParsing="false" text="Subtract" textAlignment="CENTER" onAction="#SubtractButtonPressed"/>
      <ListView fx:id="lstDisplay" layoutX="14.0" layoutY="179.0" prefHeight="147.0" prefWidth="250.0" />
      <Button fx:id="btnRemoveAll" layoutX="83.0" layoutY="333.0" mnemonicParsing="false" text="Remove from list" textAlignment="CENTER" onAction="#RemoveListButtonPressed"/>
   </children>
</AnchorPane>
FXMLDocumentController.java:
package calculator5;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.ListView;
import javafx.scene.control.TextField;

public class FXMLDocumentController {
 
    // GUI controls defined in FXML and used by the controller's code
   @FXML
   private TextField txtValue1;
   @FXML
   private TextField txtValue2;
   @FXML
   private ListView<String> lstDisplay;

   // Multiply button event
   @FXML
   private void MultiplyButtonPressed(ActionEvent event) {
            try {
                //get the value of the two input box
                Double val1 = new Double(txtValue1.getText());
                Double val2 = new Double(txtValue2.getText());
       Double result = val1 * val2; //multiply values
                lstDisplay.getItems().add(String.valueOf(val1)+ " * "+ String.valueOf(val2) +" = "+ String.valueOf(result)); //add to the listview
            } catch (Exception ex) {
                ex.printStackTrace();
            }
   }
        // Add button event
   @FXML
   private void AddButtonPressed(ActionEvent event) {
            try {
                //get the value of the two input box
                Double val1 = new Double(txtValue1.getText());
                Double val2 = new Double(txtValue2.getText());
       Double result = val1 + val2; //multiply values
                lstDisplay.getItems().add(String.valueOf(val1)+ " + "+ String.valueOf(val2) +" = "+ String.valueOf(result)); //add to the listview
            } catch (Exception ex) {
                ex.printStackTrace();
            }
   }
        // Divide button event
   @FXML
   private void DivideButtonPressed(ActionEvent event) {
            try {
                //get the value of the two input box
                Double val1 = new Double(txtValue1.getText());
                Double val2 = new Double(txtValue2.getText());
                if(val2==0) //check for the value2 is 0
                        return;
       Double result = val1 / val2; //divide values
                lstDisplay.getItems().add(String.valueOf(val1)+ " / "+ String.valueOf(val2) +" = "+ String.valueOf(result)); //add to the listview
            } catch (Exception ex) {
                ex.printStackTrace();
            }
   }
        // Subtract button event
   @FXML
   private void SubtractButtonPressed(ActionEvent event) {
            try {
                //get the value of the two input box
                Double val1 = new Double(txtValue1.getText());
                Double val2 = new Double(txtValue2.getText());
       Double result = val1 - val2; //subtract values
                lstDisplay.getItems().add(String.valueOf(val1)+ " - "+ String.valueOf(val2) +" = "+ String.valueOf(result)); //add to the listview
            } catch (Exception ex) {
                ex.printStackTrace();
            }
   }
        @FXML
   private void RemoveListButtonPressed(ActionEvent event) {
            try {
                lstDisplay.getItems().clear(); //clear the list view items
            } catch (Exception ex) {
                ex.printStackTrace();
            }
   }
}
sample output:
Chemistryexplain “#111 Design the GUI interface as shown in the picture below in Computer science, Ba computer science, Berkeley computer science, Computer science associate degree jobs

A5.fxml Value 1: 10 Value 2: 2 Multiply Divide Add Subtract 10.0*2.0 = 20.0 10.0/2.0 = 5.0 10.0 +2.0 = 12.0 10.0 - 2.0 = 8.0 Remove from list

Labels: , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home