Suche…


Einführung

Das ScrollPane ist ein Steuerelement, das eine dynamische Ansicht des Inhalts bietet. Diese Ansicht wird auf verschiedene Arten gesteuert. (Inkrement-Dekrement-Taste / Mausrad), um eine integrierte Ansicht des Inhalts zu erhalten.

A) Feste Inhaltsgröße:

Die Größe des Inhalts entspricht der des ScrollPane-Containers.

import javafx.scene.control.ScrollPane;   //Import the ScrollPane
import javafx.scene.control.ScrollPane.ScrollBarPolicy; //Import the ScrollBarPolicy
import javafx.scene.layout.Pane;

ScrollPane scrollpane;
Pane content = new Pane();  //We will use this Pane as a content

scrollpane = new ScrollPane(content);  //Initialize and add content as a parameter
scrollpane.setPrefSize(300, 300);   //Initialize the size of the ScrollPane

scrollpane.setFitToWidth(true);  //Adapt the content to the width of ScrollPane
scrollpane.setFitToHeight(true); //Adapt the content to the height of ScrollPane


scrollpane.setHbarPolicy(ScrollBarPolicy.ALWAYS);  //Control the visibility of the Horizontal ScrollBar
scrollpane.setVbarPolicy(ScrollBarPolicy.NEVER);  //Control the visibility of the Vertical ScrollBar
//There are three types of visibility (ALWAYS/AS_NEEDED/NEVER)

B) Größe des dynamischen Inhalts:

Die Größe des Inhalts ändert sich in Abhängigkeit von den hinzugefügten Elementen, die die Inhaltsgrenzen in beiden Achsen (horizontal und vertikal) überschreiten, die durch Bewegung durch die Ansicht sichtbar werden.

import javafx.scene.control.ScrollPane;   //Import the ScrollPane
import javafx.scene.control.ScrollPane.ScrollBarPolicy; //Import the ScrollBarPolicy
import javafx.scene.layout.Pane;

ScrollPane scrollpane;
Pane content = new Pane();  //We will use this Pane as a content

scrollpane = new ScrollPane();  
scrollpane.setPrefSize(300, 300);   //Initialize the size of the ScrollPane
content.setMinSize(300,300); //Here a minimum size is set so that the container can be extended.
scrollpane.setContent(content); // we add the content to the ScrollPane

Hinweis: Hier brauchen wir nicht beide Methoden (setFitToWidth / setFitToHeight).

Das ScrollPane gestalten:

Das Erscheinungsbild des ScrollPane kann leicht geändert werden, indem einige Begriffe von " CSS " verwendet werden und einige " Eigenschaften " der Kontrolle beachtet werden und natürlich etwas " Phantasie ".

A) Die Elemente, aus denen ScrollPane besteht:

Ich besitze das ursprüngliche Bild nicht, es gehört zu Orakel

B) CSS-Eigenschaften:

.scroll-bar:vertical .track{}

.scroll-bar:horizontal .track{}

.scroll-bar:horizontal .thumb{}

.scroll-bar:vertical .thumb{}


.scroll-bar:vertical *.increment-button,
.scroll-bar:vertical *.decrement-button{}

.scroll-bar:vertical *.increment-arrow .content, 
.scroll-bar:vertical *.decrement-arrow .content{}

.scroll-bar:vertical *.increment-arrow, 
.scroll-bar:vertical *.decrement-arrow{}


.scroll-bar:horizontal *.increment-button,
.scroll-bar:horizontal *.decrement-button{}

.scroll-bar:horizontal *.increment-arrow .content, 
.scroll-bar:horizontal *.decrement-arrow .content{}

.scroll-bar:horizontal *.increment-arrow, 
.scroll-bar:horizontal *.decrement-arrow{}

.scroll-pane .corner{}

.scroll-pane{}


Modified text is an extract of the original Stack Overflow Documentation
Lizenziert unter CC BY-SA 3.0
Nicht angeschlossen an Stack Overflow