Hi,
ich habe mir von code.makery ein Tutorial angeguckt und hab das nachgebaut, allerdings findet Scene Builder nicht die Reference auf meine Button Bar.
Mein JDK ist jdk1.8.0_65 64Bit, habe auch schon ein 1.8_55er 32 Bit probiert.
Soweit ich weiß, gibt es diese Button Bar seit 1.8.0u40.
Meine Scene Builder Version ist 2.0 und meine IDE Netbeans.
Im Controller der Klasse findet er die Button Bar, also den import gibt es. Also kann es nicht an Java liegen?
Hier meine Klassen:
Controller:
Problem: Im Scene Builder wird die BB nicht dargestellt, beim Ausführen des Projekts jedoch schon..
ich habe mir von code.makery ein Tutorial angeguckt und hab das nachgebaut, allerdings findet Scene Builder nicht die Reference auf meine Button Bar.
Mein JDK ist jdk1.8.0_65 64Bit, habe auch schon ein 1.8_55er 32 Bit probiert.
Soweit ich weiß, gibt es diese Button Bar seit 1.8.0u40.
Meine Scene Builder Version ist 2.0 und meine IDE Netbeans.
Im Controller der Klasse findet er die Button Bar, also den import gibt es. Also kann es nicht an Java liegen?
Hier meine Klassen:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane prefHeight="420.0" prefWidth="525.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="einnahmen.view.EintragOverviewController">
<children>
<SplitPane dividerPositions="0.5453237410071943" layoutX="153.0" layoutY="70.0" prefHeight="300.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="eintTable" layoutX="-12.0" layoutY="49.0" prefHeight="298.0" prefWidth="175.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columns>
<TableColumn fx:id="fachColumn" prefWidth="201.0" text="Fach" />
<TableColumn fx:id="noteColumn" prefWidth="79.0" text="Note" />
</columns>
<columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
</columnResizePolicy>
</TableView>
</children>
</AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<Label layoutX="104.0" layoutY="51.0" text="Entry Details" AnchorPane.leftAnchor="5.0" AnchorPane.topAnchor="5.0" />
<GridPane layoutX="43.0" layoutY="104.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="30.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>
<children>
<Label text="Fach" />
<Label text="Note" GridPane.rowIndex="1" />
<Label text="ECTS-Punkte" GridPane.rowIndex="2" />
<Label text="Semester" GridPane.rowIndex="3" />
<Label text="Versuch" GridPane.rowIndex="4" />
<Label text="Datum" GridPane.rowIndex="5" />
<Label text="Dozent" GridPane.rowIndex="6" />
<Label fx:id="fachLabel" text="Label" GridPane.columnIndex="1" />
<Label fx:id="noteLabel" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Label fx:id="ectsLabel" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<Label fx:id="semesterLabel" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<Label fx:id="versuchLabel" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="4" />
<Label fx:id="datumLabel" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="5" />
<Label fx:id="dozentLabel" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="6" />
</children>
</GridPane>
<ButtonBar fx:id="buttbar" layoutX="54.0" layoutY="250.0" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="10.0">
<buttons>
<Button mnemonicParsing="false" onAction="#handleNewEntry" text="New..." />
<Button mnemonicParsing="false" onAction="#handleEditEntry" text="Edit..." />
<Button mnemonicParsing="false" onAction="#handleDeleteEntry" text="Delete" />
</buttons>
</ButtonBar>
</children>
</AnchorPane>
</items>
</SplitPane>
</children>
</AnchorPane>
Controller:
Code:
package einnahmen.view;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import einnahmen.MainApp;
import einnahmen.model.Eintrag;
import javafx.scene.control.ButtonBar;
public class EintragOverviewController {
@FXML
private TableView<Eintrag> eintTable;
@FXML
private TableColumn<Eintrag, String> fachColumn;
@FXML
private TableColumn<Eintrag, String> noteColumn;
@FXML
ButtonBar buttbar;
@FXML
private Label fachLabel;
@FXML
private Label noteLabel;
@FXML
private Label ectsLabel;
@FXML
private Label semesterLabel;
@FXML
private Label versuchLabel;
@FXML
private Label dozentLabel;
@FXML
private Label datumLabel;
// Reference to the main application.
private MainApp mainApp;
/**
* The constructor. The constructor is called before the initialize()
* method.
*/
public EintragOverviewController() {
}
/**
* Initializes the controller class. This method is automatically called
* after the fxml file has been loaded.
*/
@FXML
private void initialize() {
// Initialize the entry table with the two columns.
fachColumn.setCellValueFactory(cellData -> cellData.getValue().fachProperty());
noteColumn.setCellValueFactory(cellData -> cellData.getValue().noteProperty());
// Clear entry details.
showEntryDetails(null);
// Listen for selection changes and show the entry details when changed.
eintTable.getSelectionModel().selectedItemProperty().addListener(
(observable, oldValue, newValue) -> showEntryDetails(newValue));
}
/**
* Is called by the main application to give a reference back to itself.
*
* @param mainApp
*/
public void setMainApp(MainApp mainApp) {
this.mainApp = mainApp;
// Add observable list data to the table
eintTable.setItems(mainApp.getEntryData());
}
/**
* Fills all text fields to show details about the entry. If the specified
* entry is null, all text fields are cleared.
*
* @param entry the entry or null
*/
private void showEntryDetails(Eintrag ein) {
if (ein != null) {
// Fill the labels with info from the entry object.
fachLabel.setText(ein.getFach());
noteLabel.setText(ein.getNote());
ectsLabel.setText(ein.getEcts());
semesterLabel.setText(ein.getSemester());
versuchLabel.setText(ein.getVersuch());
datumLabel.setText((ein.getDatum()));
dozentLabel.setText(ein.getDozent());
} else {
// Eintrag is null, remove all the text.
fachLabel.setText("");
noteLabel.setText("");
ectsLabel.setText("");
semesterLabel.setText("");
versuchLabel.setText("");
dozentLabel.setText("");
datumLabel.setText("");
}
}
/**
* Called when the user clicks on the delete button.
*/
@FXML
private void handleDeleteEntry() {
int selectedIndex = eintTable.getSelectionModel().getSelectedIndex();
if (selectedIndex >= 0) {
eintTable.getItems().remove(selectedIndex);
} else {
// Nothing selected.
Alert alert = new Alert(AlertType.WARNING);
alert.initOwner(mainApp.getPrimaryStage());
alert.setTitle("No Selection");
alert.setHeaderText("No Entry Selected");
alert.setContentText("Please select a entry in the table.");
alert.showAndWait();
}
}
/**
* Called when the user clicks the new button. Opens a dialog to edit
* details for a new entry.
*/
@FXML
private void handleNewEntry() {
Eintrag tempEntry = new Eintrag();
boolean okClicked = mainApp.showEntryEditDialog(tempEntry);
if (okClicked) {
mainApp.getEntryData().add(tempEntry);
}
}
/**
* Called when the user clicks the edit button. Opens a dialog to edit
* details for the selected entry.
*/
@FXML
private void handleEditEntry() {
Eintrag selectedEntry = eintTable.getSelectionModel().getSelectedItem();
if (selectedEntry != null) {
boolean okClicked = mainApp.showEntryEditDialog(selectedEntry);
if (okClicked) {
showEntryDetails(selectedEntry);
}
} else {
// Nothing selected.
Alert alert = new Alert(AlertType.WARNING);
alert.initOwner(mainApp.getPrimaryStage());
alert.setTitle("No Selection");
alert.setHeaderText("No Entry Selected");
alert.setContentText("Please select a entry in the table.");
alert.showAndWait();
}
}
}
Problem: Im Scene Builder wird die BB nicht dargestellt, beim Ausführen des Projekts jedoch schon..
Zuletzt bearbeitet: