Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7830537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:16:41+00:00 2026-06-02T11:16:41+00:00

I want to make a node present in a ScrollPane anchored to the top

  • 0

I want to make a node present in a ScrollPane anchored to the top (fixed on the Y axis) but capable of scrolling in the X axis. (In Java-FX 2.0)

Is this possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T11:16:42+00:00Added an answer on June 2, 2026 at 11:16 am

    You can use binding to adjust this special object position based on scrollbar position, see next code:

    public class FancyScrollPane extends Application {
    
        @Override
        public void start(Stage primaryStage) {
            ScrollPane scrollPane = new ScrollPane();
            Pane content = new Pane();
            scrollPane.setContent(content);
    
            // adding background
            content.getChildren().add(new Rectangle(500, 500, Color.GREEN));
    
            Circle immovableObject = new Circle(30, Color.RED);
            content.getChildren().add(immovableObject);
    
            primaryStage.setScene(new Scene(scrollPane, 300, 300));
            primaryStage.show();
    
            // here we bind circle Y position
            immovableObject.layoutYProperty().bind(
                    // to vertical scroll shift (which ranges from 0 to 1)
                    scrollPane.vvalueProperty()
                        // multiplied by (scrollableAreaHeight - visibleViewportHeight)
                        .multiply(
                            content.heightProperty()
                                .subtract(
                                    new ScrollPaneViewPortHeightBinding(scrollPane))));
        }
    
        // we need this class because Bounds object doesn't support binding 
        private static class ScrollPaneViewPortHeightBinding extends DoubleBinding {
    
            private final ScrollPane root;
    
            public ScrollPaneViewPortHeightBinding(ScrollPane root) {
                this.root = root;
                super.bind(root.viewportBoundsProperty());
            }
    
            @Override
            protected double computeValue() {
                return root.getViewportBounds().getHeight();
            }
        }
    
        public static void main(String[] args) { launch(); }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to modify xml file using dom ,but when I make node.getNodeValue(); it
I am going to make a client-server application using Node.js, and I want to
I want make datetimepicker in my project. Using jquery how it is possible? I
I want to make a 2 player pong game that uses websockets and node.js
I have node set with header, leading, body text etc... I want to make
I want to make an outgoing HTTP call from node.js, using the standard http.Client
I want to make a system for URL matching. It will work in this
Have a look at this code, I believe it solved CA2000 but I want
I want to make in a TreeView (winforms) that each node will have in
I'm writing a node class, and i want to make an inner node iterator

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.