Question

Obiectives: Review GUI concepts. en 1) Write a simple GUI (see below) that will display an entry GUI for the objects from LabTHIS NEEDS TO BE CODED IN JAVA LANGUAGE

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//javaFx code

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;

import javax.swing.*;
import java.util.ArrayList;
import java.util.Arrays;

public class AddPersonGUI extends Application {
    TextField txtId,txtFirstName,txtLastName,txtDegree1,
            txtDegree2,txtDegree3,txtDegree4,txtDegree5;
    Label lblId,lblTitle,lblFirstName,lblLastName,lblBirtDate,
            lblType,lblClass,lblDegrees;
    Button btnSubmit,btnReset;
    ToggleGroup btnGroup;
    RadioButton rdfaculty,rdStudent;
    DatePicker birthDatePicker;
    ComboBox comboBoxID,comboBoxClass;

    @Override
    public void start(Stage primaryStage) throws Exception {
        ObservableList<String> options =
                FXCollections.observableArrayList(
                        "Mr.",
                        "Miss.",
                        "Mrs.",
                        "Dr."
                        ,"Ms."
                );
        GridPane gridPane= new GridPane();
        //Setting size for the pane
        gridPane.setMinSize(400, 200);

        //Setting the padding
        gridPane.setPadding(new Insets(10, 10, 10, 10));

        //Setting the vertical and horizontal gaps between the columns
        gridPane.setVgap(5);
        gridPane.setHgap(5);

        //Setting the Grid alignment
        gridPane.setAlignment(Pos.TOP_LEFT);
        //=============
        lblId = new Label("ID: ");
        txtId = new TextField();
        gridPane.add(lblId,0,0,1,1);
        gridPane.add(txtId,1,0,1,1);

        //=========================
        lblTitle= new Label("Title: ");
        comboBoxID= new ComboBox();
        comboBoxID.setItems(options);
        gridPane.add(lblTitle,0,1,1,1);
        gridPane.add(comboBoxID,1,1,1,1);

        //==========================
        lblFirstName = new Label("FirstName: ");
        txtFirstName= new TextField();
        gridPane.add(lblFirstName,0,2,1,1);
        gridPane.add(txtFirstName,1,2,1,1);
        //==========================
        lblLastName = new Label("LastName: ");
        txtLastName= new TextField();
        gridPane.add(lblLastName,0,3,1,1);
        gridPane.add(txtLastName,1,3,1,1);
        //=====================================
        lblBirtDate = new Label("BirthDate: ");
        birthDatePicker = new DatePicker();
        gridPane.add(lblBirtDate,0,4,1,1);
        gridPane.add(birthDatePicker,1,4,1,1);

        //============================
        btnGroup= new ToggleGroup();
        lblType = new Label("Type: ");
        rdfaculty = new RadioButton("Faculty");
        rdStudent = new RadioButton("Student");
        //add to button group
        rdStudent.setToggleGroup(btnGroup);
        rdfaculty.setToggleGroup(btnGroup);
        gridPane.add(lblType,0,5);
        gridPane.add(rdfaculty,1,5,2,1);
        gridPane.add(rdStudent,2,5);
        //=============================
        lblClass= new Label("Class: ");
        comboBoxClass = new ComboBox();
        gridPane.add(lblClass,0,6);
        gridPane.add(comboBoxClass,1,6);

        //=====================

        lblDegrees = new Label("Degrees: ");
        txtDegree1 = new TextField();
        txtDegree2 = new TextField();
        txtDegree3 = new TextField();
        txtDegree4 = new TextField();
        txtDegree5 = new TextField();
        gridPane.add(lblDegrees,0,7);
        gridPane.add(txtDegree1,1,7);
        gridPane.add(txtDegree2,1,8);
        gridPane.add(txtDegree3,1,9);
        gridPane.add(txtDegree4,1,10);
        gridPane.add(txtDegree5,1,11);
        //========================

        btnSubmit = new Button("Submit");
        btnReset = new Button("Reset");
        gridPane.add(btnSubmit,0,12);
        gridPane.add(btnReset,1,12);


        Scene scene = new Scene(gridPane);

        primaryStage.setTitle("Person Add");
        primaryStage.setHeight(500);
        primaryStage.setWidth(350);
        primaryStage.setResizable(false);
        primaryStage.setScene(scene);
        primaryStage.show();
    }
    public static void main(String[] args)
    {
        launch(args);
    }
}

//output

Person Add ID: Title: FirstName: LastName Faculty Type: Student Class Degrees SubmitReset

//If you need any help regarding this solution.......... please leave a comment ....... thanks

Add a comment
Know the answer?
Add Answer to:
THIS NEEDS TO BE CODED IN JAVA LANGUAGE Obiectives: Review GUI concepts. en 1) Write a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java: student directory GUI You need to implement three classes: Person Student StudentDirectory StudentMain Start by...

    Java: student directory GUI You need to implement three classes: Person Student StudentDirectory StudentMain Start by implementing Person and Student classes. Once you are sure you can serialize and deserialize and ArrayList of Students to and from a file, move on to building the GUI application. Person: The Person class should implement serializable interface. It contains the following: Person's first name (String) Person's last name (String) Person's id number Person's date of birth (Date) public String toString(): This method method...

  • Please write it in Java language 2. (Myinterface.java) The program description below was found waaaaay back...

    Please write it in Java language 2. (Myinterface.java) The program description below was found waaaaay back in the archives of the Equinox history database. It is the specification for a simply "computer store storefront". Even though computer stores are now extinct, you find the idea charming and decide to use the specification as inspiration to write an interface for one of the Equinox systems. Read carefully: write your own GUI for one of the Equinox systems, drawing inspiration from the...

  • Form Processing HTML One of the most ubiquitous uses of JavaScript is validating form data on...

    Form Processing HTML One of the most ubiquitous uses of JavaScript is validating form data on the client side before it is submitted to the server. It is done everywhere because it is fast and it gives you a great deal of flexibility in how you handle errors insofar as the GUI is concerned. Attached is an image of some code I wrote (so Blackboard can't mess it up). Some things to notice that will help you with the lab....

  • Write MySQL query statements for the questions below including the output that proves the accuracy of...

    Write MySQL query statements for the questions below including the output that proves the accuracy of your solution. Your answers should be stored in a text file that captures your interaction with MySQL. 1. Find the movieID, title, year and DVDPrice of all movies where the DVD-Price is equal to the discountPrice. 2. Find the actorID, lastName, firstName, middleName, and suffix of all actors whose middleName is not NULL. 3. Suppose you remember a movie quote as “Play it again,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT