package jframescrollevent; import javafx.application.Platform; import javafx.collections.FXCollections; import javafx.embed.swing.JFXPanel; import javafx.geometry.Orientation; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.ListView; import javafx.stage.Stage; import javax.swing.JFrame; import javax.swing.SwingUtilities; /** * User: Artem * Date: Dec 12, 2011 * Time: 3:20:01 PM */ public class TestHScrolling { private static Scene createScene() { Group root = new Group(); ListView horizontalListView = new ListView(); horizontalListView.setOrientation(Orientation.HORIZONTAL); horizontalListView.setItems(FXCollections.observableArrayList( "Row 1", "Row 2", "Long Row 3", "Row 4", "Row 5", "Row 6", "Row 7", "Row 8", "Row 9", "Row 10", "Row 11", "Row 12", "Row 13", "Row 14", "Row 15", "Row 16", "Row 17", "Row 18", "Row 19", "Row 20" )); root.getChildren().add(horizontalListView); return new Scene(root); } private static void initAndShowGUI() { JFrame f = new JFrame("Swing"); f.setSize(240, 256); f.setLocationRelativeTo(null); final JFXPanel fxp = new JFXPanel(); f.add(fxp); f.setVisible(true); Platform.runLater(new Runnable() { @Override public void run() { fxp.setScene(createScene()); } }); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { initAndShowGUI(); Platform.runLater(new Runnable() { @Override public void run() { Stage t = new Stage(); t.setTitle("FX"); t.setWidth(240); t.setHeight(256); t.setScene(createScene()); t.show(); } }); } }); } }