Recherche…


Introduction

Le ScrollPane est un contrôle qui offre une vue dynamique de son contenu. Cette vue est contrôlée de différentes manières; (bouton d'incrémentation / molette de la souris) pour avoir une vue intégrale du contenu.

A) Taille du contenu fixe:

La taille du contenu sera la même que celle de son conteneur ScrollPane.

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) Taille du contenu dynamique:

La taille du contenu changera en fonction des éléments ajoutés qui dépassent les limites de contenu dans les deux axes (horizontal et vertical) visibles en se déplaçant dans la vue.

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

Note: Ici, nous n'avons pas besoin des deux méthodes (setFitToWidth / setFitToHeight).

Styling the ScrollPane:

L'apparence du ScrollPane peut être facilement modifiée, en ayant certaines notions de " CSS " et en respectant certaines " propriétés " de contrôle et en ayant bien sûr une certaine " imagination ".

A) Les éléments qui composent ScrollPane:

Je ne possède pas la photo originale, elle appartient à oracle

B) Propriétés CSS:

.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
Sous licence CC BY-SA 3.0
Non affilié à Stack Overflow