Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How can put the contact image on the application from button .and that displays the actual picture i piked on the application.. And how can

How can put the contact image on the application from button .and that displays the actual picture i piked on the application.. And how can i make the memo field multiple lines?

package finalproject;

import java.awt.Image; import java.io.File; import javafx.application.Application; import static javafx.application.Application.launch; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.CheckBox; import javafx.scene.control.ChoiceBox; import javafx.scene.control.DatePicker; import javafx.scene.control.ListView; import javafx.scene.control.Menu; import javafx.scene.control.MenuBar; import javafx.scene.control.MenuItem; import javafx.scene.control.RadioButton; import javafx.scene.layout.GridPane; import javafx.scene.text.Text; import javafx.scene.control.TextField; import javafx.scene.control.ToggleGroup; import javafx.scene.control.ToggleButton; import javafx.scene.image.ImageView; import javafx.scene.layout.Pane; import javafx.stage.FileChooser; import javafx.stage.Stage; public class FinalProject extends Application { @Override public void start(Stage stage) { /* MenuBar menuBar = new MenuBar(); Pane pane = new Pane(); pane.getChildren().add(menuBar); Menu menuFile = new Menu("File"); Menu menuHelp = new Menu("Help"); menuBar.getMenus().addAll(menuFile, menuHelp); menuFile.getItems().addAll(new MenuItem("New"), new MenuItem("Open"), new MenuItem("Print"), new MenuItem("Exit")); */ FileChooser fileChooser = new FileChooser(); Button openButton = new Button("Select a Picture"); //Label for name Text firstnameLabel = new Text("First Name"); TextField firstnameText = new TextField(); Text lastnameLabel = new Text("Last Name"); TextField lastnameText = new TextField(); Text spouseLabel = new Text("Spouse of Contact"); TextField spouseText = new TextField(); Text addressLabel = new Text("Address"); TextField addressText = new TextField(); Text cityLabel = new Text("City"); TextField cityText = new TextField(); Text stateLabel = new Text("State"); TextField stateText = new TextField(); Text zipLabel = new Text("Zip Code"); TextField zipText = new TextField(); Text dobLabel = new Text("Date of birth"); DatePicker datePicker = new DatePicker(); Text genderLabel = new Text("Gender"); ToggleGroup groupGender = new ToggleGroup(); RadioButton maleRadio = new RadioButton("Male"); maleRadio.setToggleGroup(groupGender); RadioButton femaleRadio = new RadioButton("Female"); femaleRadio.setToggleGroup(groupGender); //Label for Adress Text locationLabel = new Text("Home/Work"); //Choice box for location ChoiceBox locationchoiceBox = new ChoiceBox(); locationchoiceBox.getItems().addAll ("Home", "Work"); Text memoLabel = new Text("Memo"); TextField memoText = new TextField(); //Label for register Button buttonSave = new Button("SAVE"); Button buttonCancel = new Button("CANCEL"); //Creating a Grid Pane GridPane maingridPane = new GridPane(); //Setting size for the pane maingridPane.setMinSize(500, 400); //Setting the padding maingridPane.setPadding(new Insets(20, 20, 20, 20)); //Setting the vertical and horizontal gaps between the columns maingridPane.setVgap(5); maingridPane.setHgap(5); //Setting the Grid alignment maingridPane.setAlignment(Pos.TOP_LEFT); //Arranging all the nodes in the grid maingridPane.add(firstnameLabel, 0, 0); maingridPane.add(firstnameText, 1, 0); maingridPane.add(lastnameLabel, 0, 1); maingridPane.add(lastnameText, 1, 1); maingridPane.add(spouseLabel, 0, 2); maingridPane.add(spouseText, 1, 2); maingridPane.add(locationLabel, 0, 3); maingridPane.add(locationchoiceBox, 1, 3); maingridPane.add(addressLabel, 0, 4); maingridPane.add(addressText, 1, 4); maingridPane.add(cityLabel, 0, 5); maingridPane.add(cityText, 1, 5); maingridPane.add(stateLabel, 0, 6); maingridPane.add(stateText, 1, 6); maingridPane.add(zipLabel, 0, 7); maingridPane.add(zipText, 1, 7); maingridPane.add(dobLabel, 0, 8); maingridPane.add(datePicker, 1, 8); maingridPane.add(genderLabel, 0, 9); maingridPane.add(maleRadio, 1, 9); maingridPane.add(femaleRadio, 2, 9); maingridPane.add(memoLabel, 0, 10); maingridPane.add(memoText, 1, 10); //gridPane.add(fileChooser, 1, 10); maingridPane.add(openButton, 2, 0); //gridPane.add(, 1, 0); maingridPane.add(buttonSave, 2, 12); maingridPane.add(buttonCancel, 1, 12); //maingridPane.add(image1, 2, 12); //Styling nodes buttonSave.setStyle( "-fx-background-color: black; -fx-textfill: white;"); buttonCancel.setStyle( "-fx-background-color: black; -fx-textfill: white;"); firstnameLabel.setStyle("-fx-font: normal bold 15px 'serif' "); memoLabel.setStyle("-fx-font: normal bold 15px 'serif' "); spouseLabel.setStyle("-fx-font: normal bold 15px 'serif' "); stateLabel.setStyle("-fx-font: normal bold 15px 'serif' "); zipLabel.setStyle("-fx-font: normal bold 15px 'serif' "); addressLabel.setStyle("-fx-font: normal bold 15px 'serif' "); lastnameLabel.setStyle("-fx-font: normal bold 15px 'serif' "); cityLabel.setStyle("-fx-font: normal bold 15px 'serif' "); dobLabel.setStyle("-fx-font: normal bold 15px 'serif' "); genderLabel.setStyle("-fx-font: normal bold 15px 'serif' "); locationLabel.setStyle("-fx-font: normal bold 15px 'serif' "); //Setting the back ground color maingridPane.setStyle("-fx-background-color: BEIGE;"); //ImageView image1 = new ImageView(new Image(getClass().getResourceAsStream("C;\\Users\\user\\Desktop\\x.jpg"))); //Creating a scene object Scene scene = new Scene(maingridPane); //Setting title to the Stage stage.setTitle("Registration Form"); //Adding scene to the stage stage.setScene(scene); //Displaying the contents of the stage stage.show(); } public static void main(String args[]){ launch(args); }

private void openFile(File file) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases 11th British National Conference On Databases Bncod 11 Keele Uk July 7 9 1993 Proceedings Lncs 696

Authors: Michael F. Worboys ,Anna F. Grundy

1993rd Edition

3540569219, 978-3540569213

More Books

Students also viewed these Databases questions

Question

2. Is absorbing or consuming facts and forms a priority?

Answered: 1 week ago

Question

Apply your own composing style to personalize your messages.

Answered: 1 week ago

Question

Format memos and e-mail properly.

Answered: 1 week ago