-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
7u25
-
Windows 7 Enterprise 64-bit. Java 7u25
ScrollPane.setOnScroll(...) ScrollPane.setOnScrollStarted(...) ScrollPane.setOnScrollFinished(...) will not generate events unless attempted to "overscroll" or scroll past the end.
Sample.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane id="AnchorPane" prefHeight="480.0" prefWidth="640.0" xmlns:fx="http://javafx.com/fxml" fx:controller="javafxapplication7.SampleController">
<children>
<ScrollPane fx:id="mainScrollPane" fitToHeight="true" fitToWidth="true" minHeight="-Infinity" minWidth="-Infinity" prefHeight="480.0" prefWidth="640.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content>
<AnchorPane id="Content" minHeight="-Infinity" minWidth="-Infinity" prefHeight="1200.0" />
</content>
</ScrollPane>
</children>
</AnchorPane>
SampleController.java
package javafxapplication7;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.ScrollPane;
public class SampleController implements Initializable
{
private static long scrollCount = 0;
@FXML
private ScrollPane mainScrollPane;
@Override
public void initialize(URL url, ResourceBundle rb)
{
EventHandler<Event> scrollLogging = new EventHandler<Event>() {
@Override
public void handle(Event e)
{
System.out.println("Scrolling: " + scrollCount++);
}
};
mainScrollPane.setOnScroll(scrollLogging);
mainScrollPane.setOnScrollStarted(scrollLogging);
mainScrollPane.setOnScrollFinished(scrollLogging);
}
}
JavaFXApplication7.java
package javafxapplication7;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class JavaFXApplication7 extends Application
{
@Override
public void start(Stage stage) throws Exception
{
Parent root = FXMLLoader.load(getClass().getResource("Sample.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args)
{
launch(args);
}
}
Sample.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane id="AnchorPane" prefHeight="480.0" prefWidth="640.0" xmlns:fx="http://javafx.com/fxml" fx:controller="javafxapplication7.SampleController">
<children>
<ScrollPane fx:id="mainScrollPane" fitToHeight="true" fitToWidth="true" minHeight="-Infinity" minWidth="-Infinity" prefHeight="480.0" prefWidth="640.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content>
<AnchorPane id="Content" minHeight="-Infinity" minWidth="-Infinity" prefHeight="1200.0" />
</content>
</ScrollPane>
</children>
</AnchorPane>
SampleController.java
package javafxapplication7;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.ScrollPane;
public class SampleController implements Initializable
{
private static long scrollCount = 0;
@FXML
private ScrollPane mainScrollPane;
@Override
public void initialize(URL url, ResourceBundle rb)
{
EventHandler<Event> scrollLogging = new EventHandler<Event>() {
@Override
public void handle(Event e)
{
System.out.println("Scrolling: " + scrollCount++);
}
};
mainScrollPane.setOnScroll(scrollLogging);
mainScrollPane.setOnScrollStarted(scrollLogging);
mainScrollPane.setOnScrollFinished(scrollLogging);
}
}
JavaFXApplication7.java
package javafxapplication7;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class JavaFXApplication7 extends Application
{
@Override
public void start(Stage stage) throws Exception
{
Parent root = FXMLLoader.load(getClass().getResource("Sample.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args)
{
launch(args);
}
}