• Najnowsze pytania
  • Bez odpowiedzi
  • Zadaj pytanie
  • Kategorie
  • Tagi
  • Zdobyte punkty
  • Ekipa ninja
  • IRC
  • FAQ
  • Regulamin
  • Książki warte uwagi

Aplikacja JavaFX

VPS Starter Arubacloud
0 głosów
273 wizyt
pytanie zadane 7 lipca 2019 w Java przez Luki_ Nowicjusz (220 p.)

Witam mam problem mam napisać na zaliczenie aplikację "desktopową" ale mam mały problem. Otóż mam już pomysł na aplikację ale coś nie działa i nie jest w stanie powiedzieć dlaczego. Na moje oko wszystko gra ale dla eclipse nie.

package application;
	
import java.io.IOException;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Insets;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Button;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.RowConstraints;


public class Main_tescik extends Application {
	private static Stage primaryStage = null;
	private ObservableList<Employee> employeeData = FXCollections.observableArrayList();
	@Override
	public void start(Stage primaryStage) {
		try {
			Main_tescik.primaryStage = primaryStage;
			FXMLLoader loader = new FXMLLoader();
			loader.setLocation(Main_tescik.class.getResource("RootLayout.fxml"));
			BorderPane rootLayout = (BorderPane) loader.load();
			Scene scene = new Scene(rootLayout);
			primaryStage.setScene(scene);
			primaryStage.show();
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
	
	public static Stage getPrimaryStage() {
		return primaryStage;
	}
    public ObservableList<Employee> getEmployeeData() {
        return employeeData;
    }
    public boolean showEmployeeEditDialog(Employee person) {
        try {
            FXMLLoader loader = new FXMLLoader();
            loader.setLocation(Main_tescik.class.getResource("EmployeeEditDialog.fxml"));
            AnchorPane page = (AnchorPane) loader.load();
            Stage dialogStage = new Stage();
            dialogStage.setTitle("Edit Employee");
            dialogStage.initModality(Modality.WINDOW_MODAL);
            dialogStage.initOwner(primaryStage);
            Scene scene = new Scene(page);
            dialogStage.setScene(scene);


            EmployeeEditDialogController controller = loader.getController();
            controller.setDialogStage(dialogStage);
            controller.setEmployee(person);


            dialogStage.showAndWait();

            return controller.isOkClicked();
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        }
    }
  
	public static void main(String[] args) {
		Application.launch(args);
	}
}
package application;


import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.Alert.AlertType;
import javafx.stage.Stage;
import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import application.Main_tescik;
import application.Employee;

public class EmployeeOverviewController {
    @FXML
    private TableView<Employee> personTable;
    @FXML
    private TableColumn<Employee, String> firstNameColumn;
    @FXML
    private TableColumn<Employee, String> lastNameColumn;

    @FXML
    private Label firstNameLabel;
    @FXML
    private Label lastNameLabel;
    @FXML
    private Label streetLabel;
    @FXML
    private Label postalCodeLabel;
    @FXML
    private Label cityLabel;
    @FXML
    private Label birthdayLabel;
    @FXML
    private Label selectionLabel;
    
    @FXML
    private Button newButton;
    @FXML
    private Button editButton;
    @FXML
    private Button deleteButton;
    @FXML
    private Label hire_dateLabel;
    @FXML
    private Label dictionaryLabel;

    // Reference to the main application.
    private Main_tescik mainApp;

    /**
     * The constructor.
     * The constructor is called before the initialize() method.
     */
    public EmployeeOverviewController() {
    }

    /**
     * Initializes the controller class. This method is automatically called
     * after the fxml file has been loaded.
     */
    @FXML
    private void initialize() {
        // Initialize the person table with the two columns.
        firstNameColumn.setCellValueFactory(cellData -> cellData.getValue().firstNameProperty());
        lastNameColumn.setCellValueFactory(cellData -> cellData.getValue().lastNameProperty());
        
        // Clear person details.
        showEmployeeDetails(null);

        // Listen for selection changes and show the person details when changed.
        personTable.getSelectionModel().selectedItemProperty().addListener(
                (observable, oldValue, newValue) -> showEmployeeDetails(newValue));
        

        deleteButton.setOnAction(this::handleDeletePerson);
        newButton.setOnAction(this::handleNewPerson);
        editButton.setOnAction(this::handleEditPerson);
        
    }

    /**
     * Is called by the main application to give a reference back to itself.
     * 
     * @param mainApp
     */
    public void setMainApp(Main_tescik mainApp) {
        this.mainApp = mainApp;

        // Add observable list data to the table
        personTable.setItems(mainApp.getEmployeeData());
    }
    
    /**
     * Fills all text fields to show details about the person.
     * If the specified person is null, all text fields are cleared.
     * 
     * @param person the person or null
     */
    private void showEmployeeDetails(Employee person) {
        if (person != null) {
            // Fill the labels with info from the person object.
            firstNameLabel.setText(person.getFirstName());
            lastNameLabel.setText(person.getLastName());
            selectionLabel.setText(person.getSelection());
            streetLabel.setText(person.getStreet());
            postalCodeLabel.setText(Integer.toString(person.getPostalCode()));
            cityLabel.setText(person.getCity());
            birthdayLabel.setText(person.getBirthday().toString());
            hire_dateLabel.setText(person.getHire_Date().toString());
        } else {
            // Person is null, remove all the text.
            firstNameLabel.setText("");
            lastNameLabel.setText("");
            selectionLabel.setText("");
            streetLabel.setText("");
            postalCodeLabel.setText("");
            cityLabel.setText("");
            birthdayLabel.setText("");
            hire_dateLabel.setText("");
        }
    }
    
    /**
     * Called when the user clicks on the delete button.
     */
    @FXML
    private void handleDeletePerson(ActionEvent event) {
        int selectedIndex = personTable.getSelectionModel().getSelectedIndex();
        if (selectedIndex >= 0) {
            personTable.getItems().remove(selectedIndex);
        } else {
            // Nothing selected.
            Alert alert = new Alert(AlertType.WARNING);
            alert.initOwner(mainApp.getPrimaryStage());
            alert.setTitle("No Selection");
            alert.setHeaderText("No Person Selected");
            alert.setContentText("Please select a person in the table.");

            alert.showAndWait();
        }
    }
    
    /**
     * Called when the user clicks the new button. Opens a dialog to edit
     * details for a new person.
     */
    @FXML
    private void handleNewPerson(ActionEvent event) {
    	Employee tempPerson = new Employee();
        boolean okClicked = mainApp.showEmployeeEditDialog(tempPerson);
        if (okClicked) {
            mainApp.getEmployeeData().add(tempPerson);
        }
    }
   /* @FXML
    private void handleNewPerson(ActionEvent event) {
		try {
		FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("EmployeeEditDialog.fxml"));
		Parent root1 = (Parent) fxmlLoader.load();
		Stage stage = new Stage();
		stage.setScene(new Scene(root1));  
		stage.show();
		} catch (Exception e) {
			System.out.println("zle");
		}
    }*/

    @FXML
    private void handleEditPerson(ActionEvent event) {
    	Employee selectedPerson = personTable.getSelectionModel().getSelectedItem();
        if (selectedPerson != null) {
            boolean okClicked = mainApp.showEmployeeEditDialog(selectedPerson);
            if (okClicked) {
                showEmployeeDetails(selectedPerson);
            }

        } else {
            // Nothing selected.
            Alert alert = new Alert(AlertType.WARNING);
            alert.initOwner(mainApp.getPrimaryStage());
            alert.setTitle("No Selection");
            alert.setHeaderText("No Person Selected");
            alert.setContentText("Please select a person in the table.");

            alert.showAndWait();
        }
    }    
}
package application;


import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Button;
import javafx.scene.control.DatePicker;
import javafx.scene.control.TextField;
import javafx.stage.Stage;


import application.Employee;

public class EmployeeEditDialogController {

    @FXML
    private TextField firstNameField;
    @FXML
    private TextField lastNameField;
    @FXML
    private TextField streetField;
    @FXML
    private TextField postalCodeField;
    @FXML
    private TextField cityField;
    @FXML
    private TextField selectionField;
    @FXML
    private DatePicker birthdayField;
    @FXML
    private Button okButton;
    @FXML
    private Button cancelButton;
    @FXML
    private DatePicker hire_dateField;

    private Stage dialogStage;
    private Employee person;
    private boolean okClicked = false;

    @FXML
    private void initialize() {
    	okButton.setOnAction(this::handleOk);
    	cancelButton.setOnAction(this::handleCancel);
    }

    /**
     * Sets the stage of this dialog.
     * 
     * @param dialogStage
     */
    public void setDialogStage(Stage dialogStage) {
        this.dialogStage = dialogStage;
    }

    /**
     * Sets the person to be edited in the dialog.
     * 
     * @param person
     */
    public void setEmployee(Employee person) {
        this.person = person;

        firstNameField.setText(person.getFirstName());
        lastNameField.setText(person.getLastName());
        selectionField.setText(person.getSelection());
        streetField.setText(person.getStreet());
        postalCodeField.setText(Integer.toString(person.getPostalCode()));
        cityField.setText(person.getCity());
        birthdayField.setValue(person.getBirthday());
        hire_dateField.setValue(person.getHire_Date());
    }

    /**
     * Returns true if the user clicked OK, false otherwise.
     * 
     * @return
     */
    public boolean isOkClicked() {
        return okClicked;
    }

    /**
     * Called when the user clicks ok.
     */
    private void handleOk(ActionEvent event) {
        if (isInputValid()) {
            person.setFirstName(firstNameField.getText());
            person.setLastName(lastNameField.getText());
            person.setSelection(selectionField.getText());
            person.setStreet(streetField.getText());
            person.setPostalCode(Integer.parseInt(postalCodeField.getText()));
            person.setCity(cityField.getText());
            person.setBirthday(birthdayField.getValue());
            person.setHire_Date(hire_dateField.getValue());

            okClicked = true;
            dialogStage.close();
        }
    }

    /**
     * Called when the user clicks cancel.
     */
    private void handleCancel(ActionEvent event) {
        dialogStage.close();
    }

    /**
     * Validates the user input in the text fields.
     * 
     * @return true if the input is valid
     */
    private boolean isInputValid() {
        String errorMessage = "";

        if (firstNameField.getText() == null || firstNameField.getText().length() == 0) {
            errorMessage += "No valid first name!\n"; 
        }
        if (lastNameField.getText() == null || lastNameField.getText().length() == 0) {
            errorMessage += "No valid last name!\n"; 
        }
        if (selectionField.getText() == null || selectionField.getText().length() == 0) {
            errorMessage += "No valid last name!\n"; 
        }
        if (streetField.getText() == null || streetField.getText().length() == 0) {
            errorMessage += "No valid street!\n"; 
        }

        if (postalCodeField.getText() == null || postalCodeField.getText().length() == 0) {
            errorMessage += "No valid postal code!\n"; 
        } else {
            // try to parse the postal code into an int.
            try {
                Integer.parseInt(postalCodeField.getText());
            } catch (NumberFormatException e) {
                errorMessage += "No valid postal code (must be an integer)!\n"; 
            }
        }

        if (cityField.getText() == null || cityField.getText().length() == 0) {
            errorMessage += "No valid city!\n"; 
        }

        if (birthdayField.getValue() == null ) {
            errorMessage += "No valid birthday!\n";
        }
        if (hire_dateField.getValue() == null ) {
            errorMessage += "No valid hide date!\n";
        }

        if (errorMessage.length() == 0) {
            return true;
        } else {
            // Show the error message.
            Alert alert = new Alert(AlertType.ERROR);
            alert.initOwner(dialogStage);
            alert.setTitle("Invalid Fields");
            alert.setHeaderText("Please correct invalid fields");
            alert.setContentText(errorMessage);

            alert.showAndWait();

            return false;
        }
    }
}

Na razie jest jeden guzik na początku ale w zamyśle ma ich być więcej tylko na razie nie potrafię doprowadzić do działania tego jednego to nie ma sensu robić więcej. Aplikacja ma działać tak że wciskam guzik na RootLayout i przechodzę do EmployeeOverview(do tej pory działa) potem jak kliknę new to otwiera się EmployeeEditDialog i można dodawać dane ale już to n ie działa a ja nie mam pojęcia dlaczego.

Pomocy muszę to zrobić do środy. Tylko bładam bez komentarzy w stylu "tu cos robisz nie optymalnie" albo "to można zrobić lepiej" zależy mi tylko na ty żeby to działało.

1 odpowiedź

0 głosów
odpowiedź 7 lipca 2019 przez Luki_ Nowicjusz (220 p.)

Tu dorzucam jeszcze kody bo nie zmieściłem się w limicie:

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ButtonBar?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.text.Font?>

<AnchorPane minHeight="401.0" minWidth="700.0" prefHeight="420.0" prefWidth="700.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.EmployeeOverviewController">
   <children>
      <SplitPane dividerPositions="0.29797979797979796" layoutX="51.0" layoutY="14.0" prefHeight="382.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
        <items>
          <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
               <children>
                  <TableView fx:id="personTable" layoutX="-12.0" layoutY="22.0" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
                    <columns>
                      <TableColumn fx:id="firstNameColumn" prefWidth="75.0" text="First Name" />
                      <TableColumn fx:id="lastNameColumn" prefWidth="75.0" text="Last Name" />
                    </columns>
                     <columnResizePolicy>
                        <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
                     </columnResizePolicy>
                  </TableView>
               </children>
            </AnchorPane>
          <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="328.0" prefWidth="417.0">
               <children>
                  <Label layoutX="14.0" layoutY="14.0" text="Person Dtails">
                     <font>
                        <Font name="System Bold" size="12.0" />
                     </font></Label>
                  <GridPane layoutX="14.0" layoutY="43.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="14.0">
                    <columnConstraints>
                      <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
                      <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
                    </columnConstraints>
                    <rowConstraints>
                      <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                      <RowConstraints maxHeight="25.0" minHeight="10.0" prefHeight="19.0" vgrow="SOMETIMES" />
                        <RowConstraints maxHeight="41.0" minHeight="10.0" prefHeight="41.0" vgrow="SOMETIMES" />
                      <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                        <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                        <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                        <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                        <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                        <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                    </rowConstraints>
                     <children>
                        <Label text="First Name" />
                        <Label text="Last Name" GridPane.rowIndex="1" />
                        <Label text="Street" GridPane.rowIndex="3" />
                        <Label text="City" GridPane.rowIndex="4" />
                        <Label text="Postal Code" GridPane.rowIndex="5" />
                        <Label text="BirthDate" GridPane.rowIndex="6" />
                        <Label fx:id="firstNameLabel" text="Label" GridPane.columnIndex="1" />
                        <Label fx:id="lastNameLabel" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="1" />
                        <Label fx:id="streetLabel" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="3" />
                        <Label fx:id="cityLabel" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="4" />
                        <Label fx:id="postalCodeLabel" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="5" />
                        <Label fx:id="birthdayLabel" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="6" />
                        <Label text="Selection" GridPane.rowIndex="2" />
                        <Label fx:id="selectionLabel" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="8" />
                        <Label text="HireDate" GridPane.rowIndex="7" />
                        <Label prefHeight="17.0" prefWidth="70.0" GridPane.columnIndex="1" GridPane.rowIndex="7" />
                        <Label fx:id="hire_dateLabel" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="7" />
                        <Label fx:id="selectionLabel" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="2" />
                        <Label fx:id="dictionaryLabel" text="Dictionary" GridPane.rowIndex="8" />
                     </children>
                  </GridPane>
                  <ButtonBar layoutX="154.0" layoutY="244.0" prefHeight="40.0" prefWidth="263.0" AnchorPane.bottomAnchor="8.0" AnchorPane.rightAnchor="8.0">
                    <buttons>
                      <Button fx:id="newButton" mnemonicParsing="false" text="New..." />
                        <Button fx:id="editButton" mnemonicParsing="false" text="Edit..." />
                        <Button fx:id="deleteButton" mnemonicParsing="false" text="Delete" />
                    </buttons>
                  </ButtonBar>
               </children>
            </AnchorPane>
        </items>
      </SplitPane>
   </children>
</AnchorPane>
package application;

import java.time.LocalDate;

import application.Employee;

import java.sql.Date;

import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;


public class Employee {

	private Integer employeeID;
	private StringProperty firstName;
	private StringProperty lastName;
	private StringProperty selection;
	private StringProperty street;
	private IntegerProperty postalCode;
	private StringProperty city;
	private ObjectProperty<LocalDate> birthday;
	private ObjectProperty<LocalDate> hire_date;

	private Integer idDictionary;

	/**
	 * Default constructor.
	 */
	public Employee() {
		this.employeeID = new Integer(0);

		this.firstName = new SimpleStringProperty();
		this.lastName = new SimpleStringProperty();
		this.selection = new SimpleStringProperty();

		// Some initial dummy data, just for convenient testing.
		this.street = new SimpleStringProperty();
		this.postalCode = new SimpleIntegerProperty();
		this.city = new SimpleStringProperty();
		this.birthday = new SimpleObjectProperty<LocalDate>();
		this.hire_date = new SimpleObjectProperty<LocalDate>();

		this.idDictionary = null;
	}

	public Integer getPersonID() {
		return employeeID;
	}

	public void setPersonID(Integer personID) {
		this.employeeID = personID;
	}

	public String getFirstName() {
		return firstName.get();
	}

	public void setFirstName(String firstName) {
		this.firstName.set(firstName);
	}

	public StringProperty firstNameProperty() {
		return firstName;
	}

	public String getLastName() {
		return lastName.get();
	}

	public void setLastName(String lastName) {
		this.lastName.set(lastName);
	}

	public StringProperty lastNameProperty() {
		return lastName;
	}

	public String getStreet() {
		return street.get();
	}

	public void setStreet(String street) {
		this.street.set(street);
	}

	public StringProperty streetProperty() {
		return street;
	}

	public int getPostalCode() {
		return postalCode.get();
	}

	public void setPostalCode(int postalCode) {
		this.postalCode.set(postalCode);
	}

	public IntegerProperty postalCodeProperty() {
		return postalCode;
	}

	public String getCity() {
		return city.get();
	}

	public void setCity(String city) {
		this.city.set(city);
	}

	public StringProperty cityProperty() {
		return city;
	}

	public LocalDate getBirthday() {
		return birthday.get();
	}

	public String getBirthdayStr() {
		LocalDate dt = birthday.get();
		if (dt != null) {
			return dt.toString();
		} else {
			return new String("");
		}
	}

	public Date getBirthdaySqlDate() {
		LocalDate dt = birthday.get();
		if (dt != null) {
			return Date.valueOf(dt);
		} else {
			return null;
		}
	}

	public void setBirthday(LocalDate birthday) {
		this.birthday.set(birthday);
	}

	public ObjectProperty<LocalDate> birthdayProperty() {
		return birthday;
	}

	public Integer getIDDictionary() {
		return idDictionary;
	}

	public void setIDDictionary(Integer idDictionary) {
		this.idDictionary = idDictionary;
	}

	public LocalDate getHire_Date() {
		return hire_date.get();
	}

	public String getHire_DateStr() {
		LocalDate dt = hire_date.get();
		if (dt != null) {
			return dt.toString();
		} else {
			return new String("");
		}
	}

	public Date getHire_DateSqlDate() {
		LocalDate dt = hire_date.get();
		if (dt != null) {
			return Date.valueOf(dt);
		} else {
			return null;
		}
	}

	public void setHire_Date(LocalDate hire_date) {
        this.hire_date.set(hire_date);
    }
	public String getSelection() {
		return selection.get();
	}

	public void setSelection(String firstName) {
		this.selection.set(firstName);
	}

	public StringProperty SelectionProperty() {
		return selection;
	}
}

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ButtonBar?>
<?import javafx.scene.control.DatePicker?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.text.Font?>

<AnchorPane prefHeight="300.0" prefWidth="450.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.EmployeeEditDialogController">
   <children>
      <Label layoutX="24.0" layoutY="14.0" text="Person Dtails">
         <font>
            <Font name="System Bold" size="12.0" />
         </font>
      </Label>
      <GridPane layoutX="24.0" layoutY="53.0" prefHeight="180.0" prefWidth="415.0">
         <columnConstraints>
            <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
            <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
         </columnConstraints>
         <rowConstraints>
            <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
            <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
            <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
            <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
            <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
            <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
            <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
            <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
         </rowConstraints>
         <children>
            <Label text="First Name" />
            <Label text="Last Name" GridPane.rowIndex="1" />
            <Label text="Street" GridPane.rowIndex="3" />
            <Label text="City" GridPane.rowIndex="4" />
            <Label text="Postal Code" GridPane.rowIndex="5" />
            <Label text="BirthDate" GridPane.rowIndex="6" />
            <TextField fx:id="firstNameField" GridPane.columnIndex="1" />
            <TextField fx:id="lastNameField" GridPane.columnIndex="1" GridPane.rowIndex="1" />
            <TextField fx:id="streetField" GridPane.columnIndex="1" GridPane.rowIndex="3" />
            <TextField fx:id="cityField" GridPane.columnIndex="1" GridPane.rowIndex="4" />
            <TextField fx:id="postalCodeField" GridPane.columnIndex="1" GridPane.rowIndex="5" />
            <DatePicker fx:id="birthdayField" prefHeight="25.0" prefWidth="205.0" GridPane.columnIndex="1" GridPane.rowIndex="6" />
            <Label text="Hire Date" GridPane.rowIndex="7" />
            <DatePicker fx:id="hire_dateField" prefHeight="25.0" prefWidth="205.0" GridPane.columnIndex="1" GridPane.rowIndex="7" />
            <Label text="Selection" GridPane.rowIndex="2" />
            <TextField fx:id="selectionField" GridPane.columnIndex="1" GridPane.rowIndex="2" />
         </children>
      </GridPane>
      <ButtonBar layoutX="268.0" layoutY="254.0" prefHeight="40.0" prefWidth="192.0" AnchorPane.bottomAnchor="8.0" AnchorPane.rightAnchor="8.0">
         <buttons>
            <Button fx:id="okButton" mnemonicParsing="false" text="Ok" />
            <Button fx:id="cancelButton" mnemonicParsing="false" text="Cancel" />
         </buttons>
      </ButtonBar>
   </children>
</AnchorPane>

 

komentarz 7 lipca 2019 przez Luki_ Nowicjusz (220 p.)
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.layout.BorderPane?>

<BorderPane minHeight="400.0" minWidth="600.0" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.myControler">
   <top>
      <MenuBar BorderPane.alignment="CENTER">
        <menus>
          <Menu mnemonicParsing="false" text="File">
            <items>
              <MenuItem mnemonicParsing="false" text="Close" />
            </items>
          </Menu>
          <Menu mnemonicParsing="false" text="Help">
            <items>
              <MenuItem mnemonicParsing="false" text="About" />
            </items>
          </Menu>
        </menus>
      </MenuBar>
   </top>
   <center>
      <Button fx:id="button" mnemonicParsing="false" onAction="#handleButton" text="Button" BorderPane.alignment="CENTER" />
   </center>
</BorderPane>

 

Podobne pytania

0 głosów
1 odpowiedź 169 wizyt
0 głosów
0 odpowiedzi 641 wizyt
pytanie zadane 26 lipca 2017 w Java przez Patryk Rafał Bywalec (2,700 p.)
0 głosów
2 odpowiedzi 181 wizyt
pytanie zadane 13 marca 2023 w Java przez elvis Nowicjusz (210 p.)

93,006 zapytań

141,973 odpowiedzi

321,254 komentarzy

62,345 pasjonatów

Motyw:

Akcja Pajacyk

Pajacyk od wielu lat dożywia dzieci. Pomóż klikając w zielony brzuszek na stronie. Dziękujemy! ♡

Oto polecana książka warta uwagi.
Pełną listę książek znajdziesz tutaj

Wprowadzenie do ITsec, tom 2

Można już zamawiać tom 2 książki "Wprowadzenie do bezpieczeństwa IT" - będzie to około 650 stron wiedzy o ITsec (17 rozdziałów, 14 autorów, kolorowy druk).

Planowana premiera: 30.09.2024, zaś planowana wysyłka nastąpi w drugim tygodniu października 2024.

Warto preorderować, tym bardziej, iż mamy dla Was kod: pasja (użyjcie go w koszyku), dzięki któremu uzyskamy dodatkowe 15% zniżki! Dziękujemy zaprzyjaźnionej ekipie Sekuraka za kod dla naszej Społeczności!

...