import javafx.application.Application; import javafx.scene.Scene; import javafx.stage.Stage; import views.MainView; public class App extends Application { public static void main(String[] args) throws Exception { launch(args); } @Override public void start(Stage primaryStage) throws Exception { MainView mainView = new MainView(); primaryStage.setTitle("Text komponens"); primaryStage.setScene(new Scene(mainView)); primaryStage.show(); } }
import javafx.scene.layout.HBox; public class MainView extends HBox { InputPanel inputPanel; public MainView() { this.inputPanel = new InputPanel(); this.inputPanel.setText("Valami"); this.getChildren().add(this.inputPanel); } }
package views; import javafx.geometry.Insets; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.layout.HBox; public class InputPanel extends HBox { Label label; TextField field; public InputPanel() { this.generateComponent(); this.setComponent(); this.addComponentToPanel(); } public InputPanel(String labelText) { this.setComponent(); this.label.setText(labelText); } private void generateComponent() { this.label = new Label(); this.field = new TextField(); } private void setComponent() { HBox.setMargin(this.label, new Insets(10, 10, 10, 10)); HBox.setMargin(this.field, new Insets(10, 10, 10, 10)); this.label.setMinHeight(25); } private void addComponentToPanel() { this.getChildren().add(this.label); this.getChildren().add(this.field); } public void setText(String text) { this.label.setText(text); } public String getText() { return this.label.getText(); } public void setValue(String value) { this.field.setText(value); } public String getValue() { return this.field.getText(); } }
Ha JavaFX-t alapú forráskódhoz szeretnénk dokumentációt készíteni, akkor szükségünk lesz a --module-path és az --add-module kapcoslókra
javadoc --module-path /home/valaki/Library/javafx --add-modules=javafx.controls,javafx.fxml -d javadoc src/net/zold/Valami.java