codestory

Die Anleitung zu JavaFX TitledPane

  1. JavaFX TitledPane
  2. Das Beispiel mit TitledPane

1. JavaFX TitledPane

TitledPane ist ein Panel mit Titel und diese Panel kann geweitet (expaned) oder gescheitert (collapsed)
Constructor:
// Creates a new TitledPane with no title or content.
TitledPane()

// Creates a new TitledPane with a title and content.
TitledPane(String title, Node content)
Method:
public void setTitle(String title)
public void setContent(Node value)
public void setCollapsible(boolean value)
public boolean isCollapsible()
public void setAnimated(boolean value)
public void setExpanded(boolean value)
public boolean isExpanded()

.....

2. Das Beispiel mit TitledPane

TitledPaneDemo.java
package org.o7planning.javafx.titledpane;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TitledPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class TitledPaneDemo extends Application {

   public static void main(String[] args) {
       Application.launch(args);
   }

   @Override
   public void start(Stage stage) {

       // Create TitledPane.
       TitledPane titledPane = new TitledPane();
       titledPane.setText("Java");

       // Content for TitledPane
       VBox content = new VBox();
       content.getChildren().add(new Label("Java Swing Tutorial"));
       content.getChildren().add(new Label("JavaFx Tutorial"));
       content.getChildren().add(new Label("Java IO Tutorial"));

       titledPane.setContent(content);

        // Set Expaneded.
        titledPane.setExpanded(true);

       //
       VBox root= new VBox();
       root.setPadding(new Insets(5));
       root.getChildren().add(titledPane);
     
       Scene scene = new Scene(root, 250, 200);

       stage.setTitle("TitledPane (o7planning.org)");
       stage.setScene(scene);
       stage.show();
   }
 
}
Zum Beispiel

Die Anleitungen JavaFX

Show More