FlowPane in ScrollPane doesn't fill the horizontal width

Hi all. I'm having a problem that shows the code example below.

I would like to be able to add a variable number of nodes to an area of flow, and I would they move to a new line when they are run on the horizontal width.

If they run out of vertical width, I wish the ScrollPane to scroll vertically.

Does anyone know how to achieve this behavior?

Thank you, Nick.
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.FlowPane;
import javafx.stage.Stage;

public class LayoutTest extends Application {
    @Override
    public void start(Stage stage) throws Exception {
        stage.setTitle("LayoutTest");
        FlowPane flowPane = new FlowPane();
        ScrollPane root = new ScrollPane();
        root.setContent(flowPane);
        Scene scene = new Scene(root, 800, 400);
        for (int i = 0; i < 1000; i++) {
            Label text = new Label(" Nick " + i);
            flowPane.getChildren().add(text);
        }
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
Edited by: Boomah February 27, 2012 10:51

Add the following code to your sample:

root.viewportBoundsProperty().addListener(new ChangeListener() {
  @Override public void changed(ObservableValue bounds, Bounds oldBounds, Bounds newBounds) {
    flowPane.setPrefWidth(newBounds.getWidth());
  }
});

This will resize to width of the flowPane to fill the window of ScrollPane as the size of the viewport changes.

Tags: Java

Similar Questions

  • Storm: is it possible to resize the horizontal width of the Manager?

    Hi all

    Is it possible to resize the horizontal width of the Manager. I want to create two buttons in horizontal management, set the border background. I use the following code to do this. It works very well. But as there are only two buttons and does not occupy the whole of the 320 width screen, frame border is happening only for these two buttons background. So I could see the spaces apart from the horizontal width in front and in rear areas. So I want to create a horizontal Manager himself with a width of 320, so that the layout border color indicates the full width. Is it possible to resize the horizontal width of the Manager?
     
    XYEdges borderColor = new XYEdges (Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK);
    NoPadding XYEdges = new XYEdges (2, 2, 2, 2);

    HorizontalFieldManager hzBtnFldManager = new HorizontalFieldManager (HorizontalFieldManager.FIELD_HCENTER);

    new CustomControl = createButton ("Create", ButtonField.FOCUSABLE |) ButtonField.CONSUME_CLICK | ButtonField.FIELD_HCENTER, 83, 15);
    cancelButton = new CustomControl ("Cancel", ButtonField.FOCUSABLE |) ButtonField.CONSUME_CLICK | ButtonField.FIELD_HCENTER, 83, 15);

    hzBtnFldManager.add (createButton);
    hzBtnFldManager.add (cancelButton);

    At the border btnBarPaddingBorder = BorderFactory.createSimpleBorder (noPadding, borderColor, Border.STYLE_SOLID);
    hzBtnFldManager.setBorder (btnBarPaddingBorder);
    hzBtnFldManager.setBackground (BackgroundFactory.createSolidBackground (Color.GRAY));

    this.setStatus (hzBtnFldManager);

    Resolved using HorizontalFieldManager (Field.USE_ALL_WIDTH);

  • New samsung 23 "monitor how to fill the horizontal screen

    bought the new samsung 23 "monitor. How can I fill screen horozonially?

    A moderator has moved this thread to Windows for the hardware and drivers Forum of Feedback Forum

    Hello, Joe,

    What is the Windows operating system?

    Have you tried to change the resolution of the screen?

    http://Windows.Microsoft.com/en-us/Windows7/change-your-screen-resolution

    This will tell you what is your resolution

    http://www.whatismyscreenresolution.com/

  • Windows 7 Age of Empires II and Age of Empires III doesn't fill the entire screen

    I just finished the installation of Age of Empires II Age of Kings and the Expansion of the Concqerors on my new PC which has Windows 7.  Not only am I have problems of color with Age of Kings II, both games II and III will not fill my 27-inch (1920 x 1080) monitor.  I set the screen resolution and downloaded the latest driver for my GTX 580 of NVIDEA but nothing seems to work.  How can I solve the problems of color with Age of Kings II and how can I solve the problem with the games only using the central part of my monitor and leaving a lot of black space on both sides.  Y at - it a patch from microsoft for these questions?  If this is not the case, there should be.  Help, please.

    This is not a gambling problem. These old games only were not aware that future screen sizes might be greater than 640 x 480, probably 800 x 600 or 1024 x 768 (high end!). So there not in the set of options to set the display in today HD resolution. This adjustment can now be done by the video card driver that must be able "to scale", or you will enjoy with the size of the screen not interpolated, original (on a screen 1920 x 1080, which will only be part of your actual screen). I do not have an NVIDIA card, on my AMD card, 'scaling' option is an Advanced Catalyst Control Center setting, there should be something similar in the controls of your card.

  • Desktop doesn't fill the screen

    I have recently reinstalled the operating system on an inspiron 8100 and gave in and gave to a former friend.   The unit is having the same problem I had with it, years ago.  However, I don't remember how I fixed it then.

    The problem is that when you start the unit in place the splash screen, the bios screen will occupy only a small part of the screen.  After windows starts, it seems perfect until you set resolutions lower then a resident and then it changes the size of the office and the external parts of the screen are black.  It's as if it were a screen 8 ".

    And Yes, I have all the drivers up to date

    The first time I had this problem, I found the fix for this immediately.  He has been pressing a few keys on the keyboard and presto, back to full screen.  Unfortunately, it was several years ago and o do not remember the fix.


  • Embedded Vimeo Video fills the entire width

    When I embed a video from vimeo, it will only fill 3/4 of the area of the box. I edited the width to 100% and don't stretch not only decrease in size which I don't want.

    hope you can help thanks

    Screen Shot 2016-07-11 at 16.27.08.png

    Hello!

    If you manually set the video to the width of your maximum width (check the settings of the container) rather than the 100% setting, you should be good to go.

  • How to fill the entire width of the screen on a phone

    Hello

    I am currently doing a small mobile page with Edge. I defined the project to 640px width to fit perfectly on the screen of the iphone. However if re-directed the page in Safari there are always a few pixels on the right side that are white. Optimally the screen should be default fillesd (also if it is used by a phone with an another width in pixels). I tried to work with the persentages to get a reactivity going on but it doesn't seem to work. The band of white pixels don't disappear.

    Can someone provide me with a solution?

    See you soon!

    Try to set a meta tag for the page HTML of your project before theTag:<p class="reply"> <p class="reply"><meta name="viewport" content="width = device-width, initial-scale = 1 /></p> <p class="reply">This will make it so your page fills to the width of the viewport.</p> <p class="reply">Here's a good resource to learn more about mobile meta tags and how they can be applicable to your HTML projects</p> <p class="reply"><a href=" http://mobile.tutsplus.com/tutorials/iphone/iphone-web-app-meta-tags/"="">http://mobile.tutsplus.com/tutorials/iPhone/iPhone-web-app-meta-tags/</p> <p class="reply">Sarah</p>

  • navigation bar won't fill the entire width of the page

    Hello!

    Everything takes this page uniformly l to r except the navigation bar. If I change the width of each area of 146 to 147, it ends up being too big and the last box falls below. I tried to make 100% and makes each all width box. What I can do, so there is no space on the right? Thank you very much!

    Here is the current link on the site:

    http://kobwebsecure.com/elitedesigner/

    Have you tried adding padding 1px on the selector css below (as illustrated, second item in the list)

    UL. MenuBarHorizontal li
    {
    margin: 0;
    padding: 1px 0;
    list-style-type: none;
    do-size: 100%;
    position: relative;
    text-align: left;
    cursor: pointer;
    Width: 146px;
    float: left;
    border: thin solid #fff;
    background-color: #333;
    }

  • How to make the full width of the tab DataGrid

    I have a DataGrid inside a component.

    The component part of a ViewStack that is controlled using a TabBar.

    Even if the width of the DataGrid control is set to 100%, it never fills the width of the TabBar. Thus, for example, the TabBar fills the entire width of the browser (1024px) but the DataGrid seems only 200px wide.

    How do you guarantee that a DataGrid fills the entire width of the screen, if that's what space is available?

    How do detect you the Stage.Width property or similar in Flex 2?

    Thank you
    Martyn

    Found the solution. Necessary to set the width of the ViewStack itself to 100% as well. It was resizeToContent = "true", but without the defined width. Now it works when width = '100% ', according to the example below. Note that you have to still need resizeToContent = "true" as well as width = 100% so that it resizes vertically to take into account the height of the DataGrid.


    http://www.Adobe.com/2006/mxml"layout ="absolute"xmlns:com ="com.*"xmlns:view =" "com.view. *" > "


    [Bindable]
    public var selectedItem:Object;
    ]]>



    Christina Coenraets
    555-219-2270.
    [email protected]
    true

    <>
    ' xmlns:MX =' http://www.adobe.com/2006/mxml '
    xmlns:view = "com. View.* ".
    Width = "100%" >

















  • Is it possible fill the width of the browser without creating a horizontal scrolling?

    I am filling the width of the browser of images placed on the page so that they bleed off the coast. But as soon as I reached the edge of the work area and then preview it scrolls just to show the empty spaces.

    I'm trying to get the effect that if you're a display on a monitor screen wide you see all the pictures, but if displayed on a screen smaller than images are just purge with no option to horizontally scroll.

    Is this possible?

    If I understand your question, create a rectangle of width of 100%, or by clicking on the icon of the 100% width or drag the edge to the edge of space of the browser until the edge lights up red. Now, go to the filler panel and select Add images. Choose your image. Set location to the Center. Assign the editing Original size - this will prevent the image to resize with the browser. You will need to ensure that the images are large enough to fill the screen, of course.

  • How to make a horizontal bar stretch to fill the width of the browser outside the wrappe always

    When I get 100% in the width field, that it will fill the wrapper which is 1000px, I want just some horizontal bars to fill the width of the browser at any time.

    Example is at http://www.hollywoodunderground.com - bar under the header/links and the bar above the footer. Trying to figure out how to get both of those always fill the width of the browser while keeping the original packaging for all other content. I can just find a way to get these 2 bars outside of the package in a new package, or can I do it in the wrapper?

    You need to configure your build slightly differently.

    You will place the logo and icons of social media in their own

    the value of 1000px, margin 0 auto to Center horizontally

    Then you would have your black bar

    the value of width: 100% (no need to set even if, as it will fill the available space).

    Then you'd have your youtube videos

    the 1000px, auto margin 0 value.

    Then another black bar

    :

    Get it?

  • Watch the video on the Pearl Flip 8220 smart blackBerry phones, how to make horizontal and fill the entire screen?

    I have movies on my flip. When I look at a screen remains vertical and small. Is there a way to make the horizontal screen and use the full screen? Thank you.

    After some trial and error, I discovered, you must use the blackberry Media Manager to transfer your movies and when you move the film selected your file to your phone, you must select the option 'optimize '. When I did this it turned the film 1/4 turn so I could watch it on full screen. To make the small of DVD movies to the mpg4, I use a program called "convert M2 to Smartphone". It works well.

  • How can I move the image to the right about a half inch to fill the screen properly

    How can I move the screen picture to the right, about half a ince to fill the scree properly and allow a full view of the icons?

    The problem is with the settings of your monitor. One of the buttons on the front of your monitor will take you in the settings of your monitor. Select the option which moves the video horizontally, use the arrow keys to move the right way and press the settings button to exit. Should be pretty simple.

  • Games running in lower resolution on the desktop resolution does not fill the screen

    I have a laptop HP ENVY 17 TS with NVIDIA GT 740 M and Intel 4600HD graphics drivers and running Windows 7. Whenever I want to change the resolution in games at a lower resolution on the desktop resolution, the game shrinks to its view, leaving the couple of inches black bars on the edges. For example, if my the desktop resolution is 1920 x 1080 and I want to start a game in 1600 x 900, the game does not fill the screen, instead, it leaves an amount of empty space on the edges of the screen.

    In order to solve this problem, I tried the following steps:

    I first tried to locate the view tab in the NVIDIA Control Panel in order to define the scale/stretch in "Full screen", but my version of NVIDIA CP isn't the view tab (my NVIDIA drivers are the latest version).

    Then I discovered that I should do this in the Intel HD Graphics Control Panel. My Intel HD Graphics CP has an option named "Calibration" under display > display settings and it doesn't show the option to retain display scaling that is checked by default and does not change. Also, after searching the Internet I saw that some people suggested entering the 'advanced settings' and try to make changes. When I try to enter advanced settings, under view, it says 'this screen does not support advanced settings'.

    After trying without success, I tried the update driver Intel via their website, hoping that it can fix the problem. I ran the small Intel application on their Web site that identifies my chipset and offers me the latest driver for this chipset. Web site told me that the driver is installed on my computer is 10.18.10.3304, and there is an update for what is 15.33.18.64.3496 (or 10.18.10.3496). So I downloaded the file, but when I tried to run, it gave me this error message: "the drivre being installed is not validated for this computer. You can get the correct driver from the manufacturer of the computer. Setup will now exit. "that makes no sense.

    After trying the above steps, I'm not able to solve the problem, and I need help from someone who really knows how to solve this problem.

    Thank you.

    Solution (I hope)

    1. choose the properties of the graphic (logo Intel) option when you right click on the desktop

    2. go in view

    3. go through the resolutions on the 'Resolution' and change to this resolution (do not click Apply)

    4. for everyone to go to 'Scaling' at the bottom of the screen and change it to scale full screen (do not click Apply)

    5. Repeat until you get back to the higher resolution (that won't let you change the scale).

    6. quickly choose a few resolutions from the drop-down menu to make sure that they have changed their scale.

    I had a problem with some resoultions changing the way they were, but which should solve most of the problems.

  • Define an ImageView to fill the entire screen

    Hi veveryone,

    I need to have the ImageView stretch to fill the screen. How can I go about it?

    Should I get the height and width of the screen? If so, how?

    Thank you

    The code below does not work, it only centers the image

     Page *root = new Page;
    
        Container *container=new Container();
        container->setLayout(DockLayout::create());
        container->setBottomPadding(0);
        container->setLeftPadding(0);
        container->setTopPadding(0);
        container->setRightPadding(0);
    
        container->setBottomMargin(0);
        container->setLeftMargin(0);
        container->setTopMargin(0);
        container->setRightMargin (0);
    
        container->setParent(root);
    
        ImageView* img= ImageView::create("asset:///images/image.png");
        img->setHorizontalAlignment(HorizontalAlignment::Center);
        img->setVerticalAlignment(VerticalAlignment::Center);
        img->setScalingMethod(ScalingMethod::AspectFill);
    
        container->add(offImageView);
    
        root->setContent(container);
    

    Try this

     Page *root = new Page;
    
            Container *container=new Container();
            container->setLayout(DockLayout::create());
            container->setBottomMargin(0);
            container->setLeftMargin(0);
            container->setTopMargin(0);
            container->setRightMargin (0);
    
            container->setParent(root);
    
            ImageView* offImageView= ImageView::create("asset:///images/image.jpg");
            offImageView->setLayoutProperties(DockLayoutProperties::create().horizontal(HorizontalAlignment::Fill).vertical(VerticalAlignment::Fill));
            offImageView->setScalingMethod(ScalingMethod::AspectFill);
    
            container->add(offImageView);
    
            root->setContent(container);
    
        Application::setScene(root);
    

Maybe you are looking for

  • Upgrade CPU R400 options

    Hi, I have R400 with Celeron 575 M 2 GB of RAM, but there is a big problem - this really laptop does not work with Windows 7. I check in wikipedia that is Socket P, some of these processors supporting, but I do not know will be they really work T5670

  • Read visa does not read as specified in bytes read

  • In the Group Policy Editor, how to remove link purple (clicked)?

    In the Group Policy Editor, I clicked on the links. The links are 'policy setting' and 'properties' (as shown in the screenshots). The links turned purple after I clicked on them. It shows not only on the specific links I clicked on. It shows on all

  • EMachines W3644 debate upgrade to Windows 7 32-64 bit

    Hi, we have eMachines W3644 initially XP home edition with 1 GB of RAM; then I upgraded to Windows Vista Home Premium 32 - bit, 12/21/2013; Then, I upgraded a RAM to 2 gigabytes memory awhile back. Two questions: is it possible to upgrade eMachines W

  • New to PIX, I need help

    I have 2 problems, the first, I need to set up an ACL that will only allow certain IP addresses access to my internal W2K Terminal Server. My second question is my PIX just seems to stop working... which means, I wouldn't change a thing, just all of