Can't get scroll panes to scroll

Hi,
I have tabbed pane which have scroll panes which have (for each) a pane that has a known number of JLabels. The size of the tabbed pane and scroll panes are fixed, but the size of panes that are contained in them changes. I expected that when the size of panes become bigger then the size of the scroll pane a scroll bar would occur and do its job. But that does not happen. I use setSize method to set the size of the panes(not the scroll panes), which works fine.( I displayed the pane in a seperate window to check if it works.)
Have any ideas what I am missing?

My apologies.
I am using NetBeans, and didn't change the code it created for GUI. I am inclined to beleive that it does not make errors when creating GUI components.
Here is the method I use to populate one pane.
    public void listOffline() {
        // Clear the panel and set its size.
           // offlinePanel is the pane inside the scrollpane.
           offlinePanel.removeAll();
        offlinePanel.setSize(200, 20*offlineList.size());
        //offlinePane.setSize(200, 20*offlineList.size());
        // I need a list of strings to display.
        String[] ListString= arrayToStr(offlineList);
        int au=0;
        JLabel tempLabel;
        // Populate the list.
        for(int ii=0; ii < ListString.length; ii++) {
            // Add item number.
            if (ii%2 == 0){
                  tempLabel = new JLabel((ii/2 + 1) + ". " + ListString[ii]);
             else {
                  tempLabel=new JLabel(ListString[ii]);
            offlinePanel.add(tempLabel);
            tempLabel.setLocation(20,20*ii);
            tempLabel.setSize(200,20);
            // Name is in blue.
            if(au%2==0) {
                tempLabel.setForeground(java.awt.Color.BLUE);
            // Address is in green.
            else {
                tempLabel.setForeground(new java.awt.Color(0,140,0));
                tempLabel.setText("ftp://" + tempLabel.getText());
                final String temp = tempLabel.getText();
                // Open address in default browser if clicked.
                tempLabel.setCursor(java.awt.Cursor.getPredefinedCursor(12));
                tempLabel.addMouseListener(new java.awt.event.MouseAdapter() {
                    @Override
                    public void mouseClicked(java.awt.event.MouseEvent evt) {
                        try {
                            Runtime.getRuntime().exec(new String[]{"cmd", "/c", "start " + temp});
                        catch (Exception e) {
                            JOptionPane.showMessageDialog(null, "Error opening browser.");
            au++;
        ListString = null;
    }Edited by: acsabir on Oct 23, 2008 1:50 AM

Similar Messages

  • Can't get image in the scroll pane.

    I have written a program to show image in scrollpane. Image has put in the same directory of program. But Still I am not getting image in the scroll pane.
    Please have a look into program and let me know where I commit mistake.
    package com.lko.fx.controls;
    import javafx.application.Application;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.ScrollPane;
    import javafx.scene.image.Image;
    import javafx.scene.image.ImageView;
    import javafx.scene.paint.Color;
    import javafx.stage.Stage;
    * @author Upadhyay
    public class ScrollPaneFx extends Application{
    private Scene scene;
    private Group root;
    * @param args
    public static void main(String args[]){
    launch(args);
    * @param primaryStage
    * @throws Exception
    @Override
    public void start(Stage primaryStage) throws Exception {
    root = new Group();
    scene = new Scene(root, 300, 240, Color.WHITE);
    scrollPaneDemo();
    primaryStage.setTitle("ScrollPane Demo");
    primaryStage.setScene(scene);
    primaryStage.show();
    private void scrollPaneDemo() {
    ImageView imgView = new ImageView(new Image(this.getClass().getResourceAsStream("img.png")));
    ScrollPane spane = new ScrollPane();
    spane.setContent(imgView);
    root.getChildren().add(spane);
    Thanks in Advance!
    Regards,
    Himanshu

    Ok, check whether it is the image loading or something else in your code. Is the result of the getClass().getResource() method null or not null? Once we know that we know which direction to hunt in.
    Also I assume you are running in an IDE. Which one? Make sure the build picks up images. Maven for example won't pick them up from your 'src/java' directory.

  • I can't get the two finger scroll to work, I have changed the settings and it still does not work. What do I do?, I can't get the two finger scroll to work, I have changed the settings and it still does not work. What do I do?

    How can I get the scroll to work?

    Thanks for replying!
    It's something else to try! I am quite savy, just frustrated over what should be a simple update!!!!!
    I did however try and install iTunes 10.7 on a different computer, which is clean as I ran anitvirus on it this morning, prior to downloading itunessetup.exe and it did the same thing on there too.
    Having spent nearly two days trawling the internet for help I am beginning to wonder if it is not a problem with 10.7 itself? Seems like quite a lot of people have the same issues as me....and it can't be the same thing on everyone's computer!
    I will try the antivirus on my laptop and go from there!!!
    Thanks again for your answer.

  • How to get a scroll pane to scroll as text is appended to it?

    Hi All,
    I have a file management GUI with a JTextArea. As the application processes files, a string is appended to a textarea (in a scrollpane viewport) telling the user when a file has been copied, deleted etc. The problem is that when number of lines of text exceeds the size of the scrollpane the output stays showing the first few lines of text (the scroll bars appear as expected). Is there anyway to get the textarea to scroll automatically so that the latest strings are always displayed?
    Thanks!

    call setCaretPosition(int position) on the JTextArea
    Edited by: tjmerdian on Sep 11, 2008 8:25 AM

  • I can't get my mouse to scroll the page in finder

    On web pages and everything else i can use one finger to scroll up and down on the page.  In Finder it will not scroll, i have to find the scroll bar on the side or use the arrow keys on the keyboard.  Ive looked in mission control and looked in the magic mouse and nothing will let it work.  Any ideas?

    I'm not quite sure what you want to achieve.   What do you want in finder that you cannot move to?
    Have you noticed the small slide bar bottom right corner with which you can adjust the contents of the page.   To the left makes the page smaller and brings into view items that may be below page level.   To the right increases the size of the content and from which point your finger scrolling should work.

  • Can't get rid of vertical scroll bar for full page iviews

    Hello all,
    We 've got a number of areas of our portal where we are using iViews with a full page (e.g. web dynpro apps, collaboration directory).  However with all of these iViews, a vertical scroll bar appears on the right hand side. This bar has hardly any "play" in it (it doesn't move very far), and it doesn't reveal anything extra.
    The funny thing is, it only happens when our desktop (theme and framework) is applied.  Does anyone have any idea what might affect this?
    The iView tray height is set to full_page.  In some cases it sits within a page, others it is added directly to the workset.
    Using EP6SP14
    Thanks,
    Chris

    Hi Christopher,
    whenever a page is displayed in portal, a javascript resizes your inner page iView dynamically. The value used depends on the resolution of your browser (height) minus some pixel reserverd for your mast head, TLN and other page header iViews.
    If you use a theme or masthead iView that is higher than an original one, the javascript calculates an iView height that is too high. Maybe you should try decreasing the height of your portal header.
    At least, that's what I think. Maybe I'm wrong.
    HTH,
    Carsten

  • Scroll pane can't align it's content

    When a Node(group fro example) is added into a scroll pane, the scroll pane automatically align the node to the upper left corner of the scroll pane's content area. How can i customize the Node's alignment(the middle center eg) in the scroll pane. When the Node's size is scaled and larger than the scroll pane's size the scroll pane's scroll bar appears, and if the Node's size shrinks and it's size becomes smaller than the scroll pane's then the Node is aligned to the middle center. it seems don't take affect if i override the scroll pane's layoutChildren method and set layoutX and layoutY property of the Node.
    If any one can give me some clue?
    thanks

    ScrollPanes are somewhat tricky to use. They don't align content, you need to use layout managers to do that or you need to layout yourself with shapes in groups using absolute co-ordinates and/or translations. The ScrollPane defines it's own viewport related coordinates and you need to layout your content within that viewport.
    How can i customize the Node's alignment(the middle center eg) in the scroll pane.Get the layoutBoundsInParent of the node, get the viewportBounds of the scrollpane and perform the translation of the node such that the center of the node is in the center of the viewportBounds (will require a little bit of basic maths to do this) by adding listeners on each property.
    When the Node's size is scaled and larger than the scroll pane's size the scroll pane's scroll bar appears, and if the Node's size shrinks and it's size becomes smaller than the scroll pane's then the Node is aligned to the middle center.Similar to above, just work with those properties.
    Not exactly a direct answer to your question, but you could try playing around with the following code if you like Saludon. It is something I wrote to learn about JavaFX's layoutbounds system. Resizing the scene and toggling items on and off will allow you to see the scroll pane. The view bounds listeners show you the properties you are interested in to achieve the effect you want.
    import javafx.application.Application;
    import javafx.beans.value.*;
    import javafx.event.*;
    import javafx.geometry.Bounds;
    import javafx.scene.Node;
    import javafx.scene.Scene;
    import javafx.scene.control.*;
    import javafx.scene.effect.DropShadow;
    import javafx.scene.layout.*;
    import javafx.scene.layout.VBox;
    import javafx.scene.paint.Color;
    import javafx.scene.shape.*;
    import javafx.stage.Stage;
    public class LayoutBoundsScrollableAnchorPane extends Application  {
      // define some controls.
      final ToggleButton stroke    = new ToggleButton("Add Border");
      final ToggleButton effect    = new ToggleButton("Add Effect");
      final ToggleButton translate = new ToggleButton("Translate");
      final ToggleButton rotate    = new ToggleButton("Rotate");
      final ToggleButton scale     = new ToggleButton("Scale");
      public static void main(String[] args) { launch(args); }
      @Override public void start(Stage stage) throws Exception {
        // create a square to be acted on by the controls.
        final Rectangle square = new Rectangle(20, 30, 100, 100); //square.setFill(Color.DARKGREEN);
        square.setStyle("-fx-fill: linear-gradient(to right, darkgreen, forestgreen)");
        // show the effect of a stroke.
        stroke.setOnAction(new EventHandler<ActionEvent>() {
          @Override public void handle(ActionEvent actionEvent) {
            if (stroke.isSelected()) {
              square.setStroke(Color.FIREBRICK); square.setStrokeWidth(10); square.setStrokeType(StrokeType.OUTSIDE);
            } else {
              square.setStroke(null); square.setStrokeWidth(0.0); square.setStrokeType(null);
            reportBounds(square);
        // show the effect of an effect.
        effect.setOnAction(new EventHandler<ActionEvent>() {
          @Override public void handle(ActionEvent actionEvent) {
            if (effect.isSelected()) {
              square.setEffect(new DropShadow());
            } else {
              square.setEffect(null);
            reportBounds(square);
        // show the effect of a translation.
        translate.setOnAction(new EventHandler<ActionEvent>() {
          @Override public void handle(ActionEvent actionEvent) {
            if (translate.isSelected()) {
              square.setTranslateX(100);
              square.setTranslateY(60);
            } else {
              square.setTranslateX(0);
              square.setTranslateY(0);
            reportBounds(square);
        // show the effect of a rotation.
        rotate.setOnAction(new EventHandler<ActionEvent>() {
          @Override public void handle(ActionEvent actionEvent) {
            if (rotate.isSelected()) {
              square.setRotate(45);
            } else {
              square.setRotate(0);
            reportBounds(square);
        // show the effect of a scale.
        scale.setOnAction(new EventHandler<ActionEvent>() {
          @Override public void handle(ActionEvent actionEvent) {
            if (scale.isSelected()) {
              square.setScaleX(2);
              square.setScaleY(2);
            } else {
              square.setScaleX(1);
              square.setScaleY(1);
            reportBounds(square);
        // layout the scene.
        final AnchorPane anchorPane = new AnchorPane();
        AnchorPane.setTopAnchor(square,  0.0);
        AnchorPane.setLeftAnchor(square, 0.0);
        anchorPane.setStyle("-fx-background-color: cornsilk;");
        anchorPane.getChildren().add(square);
        // add a scrollpane and size it's content to fit the pane (if it can).
        final ScrollPane scrollPane = new ScrollPane();
        scrollPane.setContent(anchorPane);
        square.boundsInParentProperty().addListener(new ChangeListener<Bounds>() {
          @Override public void changed(ObservableValue<? extends Bounds> observableValue, Bounds oldBounds, Bounds newBounds) {
            anchorPane.setPrefSize(Math.max(newBounds.getMaxX(), scrollPane.getViewportBounds().getWidth()), Math.max(newBounds.getMaxY(), scrollPane.getViewportBounds().getHeight()));
        scrollPane.viewportBoundsProperty().addListener(
          new ChangeListener<Bounds>() {
          @Override public void changed(ObservableValue<? extends Bounds> observableValue, Bounds oldBounds, Bounds newBounds) {
            anchorPane.setPrefSize(Math.max(square.getBoundsInParent().getMaxX(), newBounds.getWidth()), Math.max(square.getBoundsInParent().getMaxY(), newBounds.getHeight()));
        // layout the scene.
        VBox controlPane = new VBox(10);
        controlPane.setStyle("-fx-background-color: linear-gradient(to bottom, gainsboro, silver); -fx-padding: 10;");
        controlPane.getChildren().addAll(
          HBoxBuilder.create().spacing(10).children(stroke, effect).build(),
          HBoxBuilder.create().spacing(10).fillHeight(false).children(translate, rotate, scale).build()
        VBox layout = new VBox();
        VBox.setVgrow(scrollPane, Priority.ALWAYS);
        layout.getChildren().addAll(scrollPane, controlPane);
        // show the scene.
        final Scene scene = new Scene(layout, 300, 300);
        stage.setScene(scene);
        stage.show();
        reportBounds(square);
      /** output the squares bounds. */
      private void reportBounds(final Node n) {
        StringBuilder description = new StringBuilder();
        if (stroke.isSelected())       description.append("Stroke 10 : ");
        if (effect.isSelected())       description.append("Dropshadow Effect : ");
        if (translate.isSelected())    description.append("Translated 100, 60 : ");
        if (rotate.isSelected())       description.append("Rotated 45 degrees : ");
        if (scale.isSelected())        description.append("Scale 2 : ");
        if (description.length() == 0) description.append("Unchanged : ");
        System.out.println(description.toString());
        System.out.println("Layout Bounds:    " + n.getLayoutBounds());
        System.out.println("Bounds In Local:  " + n.getBoundsInLocal());
        System.out.println("Bounds In Parent: " + n.getBoundsInParent());
        System.out.println();
    }

  • I have a new mac pro and can't get a side scroll bar.  What can I do to get this?

    I have a new mac pro and can't get a side scroll bar.  How can I get this?

    The scroll bar is now set to appear automatically when you start scrolling with a trackpad or scroll wheel mouse. If you are using an mouse without a scrolling device, you should change a setting.
    In System Preferences, click General, and in the Show Scroll Bars section, click the option for how you want it to work. If you want to see them all the time click "Always."

  • Scrolling pane to view selected node

    I have a JTree which is inside of a JScrollPane. I sometimes use setSelectionPath(TreePath) to expand a particular Node, but usually it's outside of the viewing area so you don;t notice it. What's the easiest way to get the scroll pane to scroll so the newly selected node is visible?

    no problem! I haven't figured how to start that project yet... may take a while before I can find a way to do it. Hey thanks for the link, works great now

  • Can't see the horizontal scroll bar in the scroll pane.

    Hi there,
    I have created a JScrollPane object for a JTable. Using the code below, I am trying to create a horizontal scroll pane for the JTable object but the horizontal
    bar doesn't move at all. this is the code. Also when I create the horizontal bar as "AS_NEEDED" the horizontal bar does not appear. The vertical bar works
    properly. Can someone help me with this please.
    This is the Code:
    loadTableScrollPane = new JScrollPane(getLoadTable()); //"getLoadTable()" return a JTable object.
    loadTableScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    loadTableScrollPane.setViewportView(getLoadTable());
    loadTableScrollPane.setBounds(new Rectangle(5, 149, 1135, 232));

    alisadri wrote:
    Hi there,
    I have created a JScrollPane object for a JTable. Using the code below, I am trying to create a horizontal scroll pane for the JTable object but the horizontal
    bar doesn't move at all. this is the code. Also when I create the horizontal bar as "AS_NEEDED" the horizontal bar does not appear. The vertical bar works
    properly. Can someone help me with this please.
    This is the Code:
    loadTableScrollPane = new JScrollPane(getLoadTable()); //"getLoadTable()" return a JTable object.
    loadTableScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    loadTableScrollPane.setViewportView(getLoadTable());
    loadTableScrollPane.setBounds(new Rectangle(5, 149, 1135, 232));
    Just a wild guess ... because you do need to post a real example - but get rid of the setBounds and setPreferredSize and use pack() on the frame.

  • A box with a blue outline appeared in my bookmark drop-down menu. I can't get rid of it, and it obstructs the view of the bookmarks as I scroll up or down. Help!

    I was trying to bookmark a page, using the "Choose" menu in the bookmarks. I must have touched a key by accident, and a box with a blue outline & the name of one of my folders appeared in my bookmark drop-down menu. At first the box contained the folder name, then I was trying to delete the box, and erase the name, thinking it might get rid of the box, but it didn't. I can't get rid of this box! It obstructs the view of what is underneath. It stays in the same position as I scroll up & down in the drop-down menu, and it hides what is underneath. Please help me get rid of this box. It is driving me crazy! Thanks!

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    See also:
    *http://kb.mozillazine.org/Corrupt_localstore.rdf

  • How can I get a search bar added to my email archives screen to make it easier to search for the right archives folder, Samsung has one so I was surprised to see that I have to scroll up and down to find the right folder?

    How can I get a search bar added to my email archives screen to make it easier to search for the right archives folder, Samsung has one so I was surprised to see that I have to scroll up and down to find the right folder?

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    * https://support.mozilla.com/kb/Safe+Mode
    * https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes
    You can modify the pref <b>keyword.URL</b> on the <b>about:config</b> page to use Google's "I'm Feeling Lucky" or Google's "Browse By Name".
    * Google "I'm Feeling Lucky": http://www.google.com/search?btnI=I%27m+Feeling+Lucky&ie=UTF-8&oe=UTF-8&q=
    * Google "Browse by Name": http://www.google.com/search?ie=UTF-8&sourceid=navclient&gfns=1&q=
    * http://kb.mozillazine.org/keyword.URL
    * http://kb.mozillazine.org/Location_Bar_search

  • I've received a message that says my message can't be sent.  Unfortunately, the list of recipients is so long I can't see the bottom to click "try another server".  The message won't scroll.  How can I get to the options at the bottom?

    I've received an error messagae that says my message can't be sent.  Unfortunately, the recipient list is so long I can't see the bottom of the error message to click "Try again" or another option.  The message won't scroll.  How can I get to the bottom of the message?

    Many Thanks, Kurt.
    I knew I'd seen the solution you've provided somewhere - either in MacWorld or MacFormat - but couldn't remember the Gatekeeper bit!
    I shall save it somewhere VERY safe now in case this happens again …
    You have made an old man very happy and saved me from worrying that senile decay had suddenly set in. (I was 70 last week so you might understand the situation from that.)
    Best wishes
    OllyanDinah

  • How can i get the footer bar to stay, whilst page scrolls?

    how can i get the footer bar to stay, whilst page scrolls?
    at the moment, on my site, if the page is longer than the screen, it goes behind the footer,
    but the foot bar moves up the page as yo scroll down to see the rest of the content.
    any way of getting the footer to stay put, while body/page contant scrolls ?
    thanks

    You can use some css to do it...
    #footer_id {
         position:fixed;
         bottom:0px;
    <div id="footer_id">Your footer content</div>
    The css above will lock your footer to the bottome of the browser window. As long as your footer <div> is last in your html, it will float over the top of everything on your page when the page is scrolled. If it's not last in the html, you'll need to add a z-index to get it on top of your other content in the stack.

  • Just downloaded Mountain Lion and want to remove natural scrolling; I went to system preferences, but I don't have a mouse. How can I get that to open to change the scrolling?

    Just downloaded Mountain Lion and want to remove natural scrolling; I went to system preferences, but I don't have a mouse. How can I get that to open to change the scrolling?

    Trackpad System Prefs, Scroll & Zoom

Maybe you are looking for

  • (long) Stuck button after minor drop - seems to be a problem for many

    And it won't go away. I visited iPhone Feedback and sent the following; I thought I'd share it here, too: The phone is beautiful in its simplicity and is easy enough to use that even my octogenarian grandfather was able to navigate and use it with ea

  • Kernel_Task High CPU Usage (300%) and Fan Speed - On Battery and Plugged In

    Hi Everyone, Came here to ask for help given my bad situation with MBA 13 Mid-2013 (Mavericks 10.9.2). Yesterday I`ve opened my MBA and it was very laggy and sluggish, and I could hear the fan going crazy on speed. After opening Activity Monitor, Ker

  • ABAP mapping issue

    Hi, I am using abap mapping to translate xml source to xml target. Source and Target file remains same except for one particular text node. Source Structure is <SYNC_PROJINFO_004>        <CNTROLAREA>               <BSR>                       <VERB va

  • Webservice with attachments

    Hi All, I wanted to checkin a document as an Attachment via web service in UCM. When i run the service from the client i get an error message saying Content item 'CT_000014' was not successfully checked in. The content item must have a primary file.

  • Dot in xml tag

    I've a pie chart whose dataprovider is from xml source. problem is "xml contains tags containing dots" for eg : <data>               <data.emp>                          <full.name></full.name>                          <last.name></last.name>