How to re-position scroll pane contents?

I have a JSplitPane where the top half of the component contains a list of topics and the bottom half contains a scroll pane with a text area inside it. The user clicks a list item and the text for it is shown below it.
The problems is when the text area exceeds the viewable area, the bottom-most portion of the text is shown instead of the top-most portion. In other words, if the text contains 6 lines and the viewable area is 4 lines, I'm seeing lines 3-6 instead of 1-4.
One would think this is a very easy solution, such as:
SplitTextScrollPane.getVerticalScrollBar().setValue(0);
However, that doesn't work (at least not in JDK 1.3.0c). How do you programatically scroll the text back to the top line?
Thank you.

Thanks, that worked.
I'm still a little curious about how to manually control the position of a scrollpane's contents -- for example, when the scroll pane contains things besides a text area (such as a JList or something).

Similar Messages

  • How to add a scroll pane for a panel.

    Hi
    i have a panel with some images drawn . i want a scroll pane added to this panel.
    I tried adding it but failed.
    Any suggestions please (
    here is my code.
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.Panel;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    class frame extends JFrame
         public frame()
              JScrollPane pane=new JScrollPane();
              setContentPane(new  DrawClass());
              setSize(500,300);
              setBounds(200,300, 100, 500);
              setVisible(true);
    public class DrawClass extends JPanel implements ActionListener {
         public DrawClass(){
               public void paintComponent(Graphics g){
                          super.paintComponent(g);
                    String [] Filenames={"im3","im4","im5","im6"};
                   int imgX = 0;
                   int imgY = 10;
                   Toolkit toolkit = Toolkit.getDefaultToolkit();
                   Integer[] intArray = new Integer[Filenames.length];
                   for (int i = 0; i < Filenames.length; i++)
                        intArray[i] = new Integer(i);
                       if (Filenames[i] != "" )
                            //XMLFileParser r=new XMLFileParser();
                             Image img =toolkit.getImage( "/home/swathi/Desktop/Images/"+ Filenames[i]+ ".jpg" );
                           g.drawImage (img, imgX, imgY, this);                                       
                           imgY=imgY+100;                  
                       else
                            System.out.println("NO file Found");
               public static void main(String[] args){
               frame f =new frame();
              public void actionPerformed(ActionEvent e) {
                   // TODO Auto-generated method stub
         

    can you please help me in this code .....
    DrawClass.
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.Panel;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    class frame extends JFrame
         public frame()
              setContentPane(new  DrawClass());
              setSize(500,300);
              setBounds(200,300, 100, 500);
              setVisible(true);
    public class DrawClass extends JPanel implements ActionListener {
         public DrawClass(){
               public void paintComponent(Graphics g){
                          super.paintComponent(g);
                    String [] Filenames={"im3","im4","im5","im6"};
                   int imgX = 0;
                   int imgY = 10;
                   Toolkit toolkit = Toolkit.getDefaultToolkit();
                   Integer[] intArray = new Integer[Filenames.length];
                   for (int i = 0; i < Filenames.length; i++)
                        intArray[i] = new Integer(i);
                       if (Filenames[i] != "" )
                            //XMLFileParser r=new XMLFileParser();
                             Image img =toolkit.getImage( "/home/swathi/Desktop/Images/"+ Filenames[i]+ ".jpg" );
                           g.drawImage (img, imgX, imgY, this);                                       
                           imgY=imgY+100;                  
                       else
                            System.out.println("NO file Found");
               public static void main(String[] args){
               frame f =new frame();
              public void actionPerformed(ActionEvent e) {
                   // TODO Auto-generated method stub
         ListClass
    import java.awt.*;
    import java.awt.event.*;
    import java.util.Vector;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.dnd.*;
    import javax.swing.*;
    import java.awt.Component;
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.image.ImageObserver;
    import java.awt.Toolkit;
    import javax.swing.*;
    import org.w3c.dom.Node;
         public class ListClass extends JPanel{
              ListClass(){
                   DrawClass d=new DrawClass();
              My question is how i can call a method of DrawClass which contains the drawn images ; in the List Class.
    its very urgent please.....

  • 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

  • Scroll Pane content doesn't work

    ok, so i've got a movie with a scrollpane (god these things
    are a hassle) on the stage. the movie tells the scrollpage to load
    content from an outside swf called testes.swf (short for
    testimonials). in testes.swf, there are a series of invisable
    buttons on top of client testimonials. when you press the button,
    it calls a startDrag for a movie that is sitting off the stage. the
    button code is such:
    on (press) {
    hedy.startDrag(true);
    hedy._visible = true;
    on (rollOut) {
    hedy._visible = false;
    this all works fine then the testes.swf is previewed by
    itself, but when it is loaded as content into the scrollPane, the
    button functions don't work. is it a file path issue? please help
    me! this is the last problem in a very frustrating process that has
    beenthe creation of this project.
    thanks,
    morgan

    i wonder why i bother with this forum sometimes. i always end
    up answering my own questions an hour later. so the problem was
    that the testes.swf was using a startDrag function and the
    scrollPane in which it resided has its startDrag set to true. i
    guess you can't have both elements dragging at the same time. would
    cause serious upset. so yeah, there you go.

  • Dynamic content in scroll pane component

    As far as I can see, the contentPath for a scroll pane
    component can only point to a movie clip in the library, not to an
    instance on stage. Does this mean that the content can only be
    something created during authoring with no possibility of modifying
    it in Actionscript?

    No, I had no reply and eventually wrote my own scroll pane
    solution which allows me to directly modify the pane's content with
    ActionScript and update the scroll bar to reflect any change in the
    content's size. I'm puzzled by the help file's example in
    ScrollPane.refreshPane() because it describes a senario where:
    "for example, you've loaded a form into a scroll pane and an
    input property (for example, a text field) has been changed by
    ActionScript. In this case, you would call refreshPane() to reload
    the same form with the new values for the input properties."
    Which implies that you can use ActionScript to change the
    content then reload it. The help file on ScrollPane.contentPath is
    not very clear about what content can be used but appears to say
    that the only content types allowed are: a SWF or JPEG loaded via
    its URL or a symbol in the current library. I don't see how you
    could use ActionScript to change any of these. I've tried
    specifying an on-stage instance as the content but that
    fails.

  • Why does the content spill over and how do I position this under the menu and title?

    I was following this tutorial on how to add a scrolling image gallery to a Flash website.
    (http://www.republicofcode.com/tutorials/flash/xmlimagegallery/index.php)
    From what I understand from this tutorial, it is just a matter of copying the Actionscript code and pasting it onto the timelines then making modifications on the XML.
    (kindly see a screenshot of timeline layers I made and as to where I put the Actionscript code:
    http://i429.photobucket.com/albums/qq19/tsujzpie/imagegalleryproblem_01.jpg )
    I pasted the code onto the blank keyframe labeled "Gallery"...
    But all I get is this weird effect when I click on the button for the gallery...
    (kindly see a screenshot of it here: http://i429.photobucket.com/albums/qq19/tsujzpie/imagegalleryproblem_02.jpg )
    When you put a blank keyframe on a timeline, any content put in there is supposed to only be contained in that very frame, right? How come then that - whenever the gallery button is clicked on - the content from that section spills out onto the other sections even when I click on other button for the other areas?
    I just really couldn't think why this is happening - any reason why this is so?
    And how do I position the gallery right under the section header and menu bar?
    Here is its AS2 code, by the way:
              import mx.transitions.Tween;
              import mx.transitions.easing.*;
              var myGalleryXML = new XML();
              myGalleryXML.ignoreWhite = true;
              myGalleryXML.load("gallery.xml");
              myGalleryXML.onLoad = function() {
                        _root.gallery_x = myGalleryXML.firstChild.attributes.gallery_x;
                        _root.gallery_y = myGalleryXML.firstChild.attributes.gallery_y;
                        _root.gallery_width = myGalleryXML.firstChild.attributes.gallery_width;
                        _root.gallery_height = myGalleryXML.firstChild.attributes.gallery_height;
                        _root.myImages = myGalleryXML.firstChild.childNodes;
                        _root.myImagesTotal = myImages.length;
                        _root.thumb_height = myGalleryXML.firstChild.attributes.thumb_height;
                        _root.thumb_width = myGalleryXML.firstChild.attributes.thumb_width;
                        _root.full_x = myGalleryXML.firstChild.attributes.full_x;
                        _root.full_y = myGalleryXML.firstChild.attributes.full_y;
                        callThumbs();
                        createMask();
                        scrolling();
              function callThumbs() {
                        _root.createEmptyMovieClip("container_mc",_root.getNextHighestDepth());
                        container_mc._x = _root.gallery_x;
                        container_mc._y = _root.gallery_y;
                        var clipLoader = new MovieClipLoader();
                        var preloader = new Object();
                        clipLoader.addListener(preloader);
                        for (i=0; i<myImagesTotal; i++) {
                                  thumbURL = myImages[i].attributes.thumb_url;
                                  myThumb_mc = container_mc.createEmptyMovieClip(i,           container_mc.getNextHighestDepth());
                                  myThumb_mc._y = _root.thumb_height*i;
                                  clipLoader.loadClip("thumbs/"+thumbURL,myThumb_mc);
                                  preloader.onLoadStart = function(target) {
                                            target.createTextField("my_txt",target.getNextHighestDepth          (),0,0,100,20);
                                            target.my_txt.selectable = false;
                                  preloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
                                            target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);
                                  preloader.onLoadComplete = function(target) {
                                            new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
                                            target.my_txt.removeTextField();
                                            target.onRelease = function() {
                                                      callFullImage(this._name);
                                            target.onRollOver = function() {
                                                      this._alpha = 50;
                                            target.onRollOut = function() {
                                                      this._alpha = 100;
              function callFullImage(myNumber) {
                        myURL = myImages[myNumber].attributes.full_url;
                        myTitle = myImages[myNumber].attributes.title;
                        _root.createEmptyMovieClip("fullImage_mc",_root.getNextHighestDepth());
                        fullImage_mc._x = _root.full_x;
                        fullImage_mc._y = _root.full_y;
                        var fullClipLoader = new MovieClipLoader();
                        var fullPreloader = new Object();
                        fullClipLoader.addListener(fullPreloader);
                        fullPreloader.onLoadStart = function(target) {
                                  target.createTextField("my_txt",fullImage_mc.getNextHighestDepth          (),0,0,200,20);
                                  target.my_txt.selectable = false;
                        fullPreloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
                                  target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);
                        fullPreloader.onLoadComplete = function(target) {
                                  new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
                                  target.my_txt.text = myTitle;
                        fullClipLoader.loadClip("full_images/"+myURL,fullImage_mc);
              function createMask() {
                        _root.createEmptyMovieClip("mask_mc",_root.getNextHighestDepth());
                        mask_mc._x = _root.gallery_x;
                        mask_mc._y = _root.gallery_y;
                        mask_mc.beginFill(0x000000,100);
                        mask_mc.lineTo(_root.gallery_width,0);
                        mask_mc.lineTo(_root.gallery_width,_root.gallery_height);
                        mask_mc.lineTo(0,_root.gallery_height);
                        mask_mc.lineTo(0,0);
                        container_mc.setMask(mask_mc);
              function scrolling() {
                        _root.onEnterFrame = function() {
                                  container_mc._y += Math.cos(((mask_mc._ymouse)/mask_mc._height)          *Math.PI)*15;
                                  if (container_mc._y>mask_mc._y) {
                                            container_mc._y = mask_mc._y;
                                  if (container_mc._y<(mask_mc._y-(container_mc._height-mask_mc.          _height))) {
                                            container_mc._y = mask_mc._y-(container_mc._height-          mask_mc._height);

    You should create a manually movieclip symbol with nothing in it and take a copy of it from the library and place it in the frame where you intend for the gallery to display.  Give it an instance name of "container_mc" and remove the following line from your callThumbs function
    _root.createEmptyMovieClip("container_mc",_root.getNextHigh estDepth());
    You probably need to do the same for the mask and the full images since they appear to also be created using dynamic mc's.

  • 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();
    }

  • How to scroll at the bottom using scroll pane

    i am having a label in which i have added a scroll pane. dynamically i will add some text to the label. the scroll bar should move to the buttom after addition of text so that the new text added should be visible.
    please provide me a solution.

    Swap from using a JLabel to a JTextArea, then use below to set position viewed. (do this after each time you enter any text)
    yourJTextArea.setCaretPosition(yourJTextArea.getText().length());

  • How to scroll the contents of the table without scrolling tab/colmn headers

    how to scroll the contents of the table without scrolling table and column headers in WebDynPro.
    I have set the table properties as
    footer visible = false;
    Visible row count = -1;
    and have put the table into scroll container with some specified height.
    I dont want to use the footer as I have used many tables in the container in same row and with same <b>Data node</b>.
    I have used many tables in same row and with same context node to differentiate it with two different colors for that specific columns.
    I am using <b>NW 04</b> and not NW04s.
    Please help me regarding this.

    To print the whole data of your table you have to do it yourself. The showPrintablePageBehavior only print what you actually see on the page. It does not traverse the data.
    The normal way to handle tis is to use a report generator (like itext, jasper report, fop ...).
    Timo

  • How to use scroll pane

    Can anyone tell me where a good tutorial might be on flash
    components and how to use them.....specifically the scroll pane
    component? Ive scanned some flash tutorial sites but havent really
    found any that explain how to use the components flash comes with.
    Thank you.

    Try this tutorial.
    http://www.cbtcafe.com/flash/scrollpane/index.html

  • Scroll pane refresh content

    I have background in as3, but this is my first attempt at
    building an application with classes.
    I have a scrollpane that populates with an image.
    MyScroll.as
    public var sp:ScrollPane=new ScrollPane();
    public var imagePath:String = "images/cover.jpg";
    public function createScrollPane(imagePath:String):void {
    sp.move(0,40);
    sp.source = imagePath;
    addChild(sp);
    I have a navigation at the bottom that returns the image name
    from an array that I want to refresh/load/source the scrollpane
    with, but none will work!
    SpreadNav.as
    public function _loadPage(evt:MouseEvent) {
    var str:String = evt.target.name;
    var mySlice = str.substr(10);
    myLoadImages.loadImage();
    myScrollCall.reCreateScrollPane(myNpXMLToArray.highArray[mySlice]);
    I also have a button generated that does reload the
    scrollpane, so I know that it can replace the source.
    MyScroll.as
    public function setClick():void {
    var refreshButton:Button = new Button();
    refreshButton.emphasized = true;
    refreshButton.label = "refreshPane()";
    refreshButton.move(10, 10);
    refreshButton.addEventListener(MouseEvent.CLICK,
    clickHandler);
    addChild(refreshButton);
    public function clickHandler(event:MouseEvent):void {
    sp.source = "images/1.jpg";
    But when I try to load it from the array nothing
    happens...and I have tried putting the image name right in there,
    from the array, refresh, source, contentPath is old, redraw(true)
    is old and I am running out of things to try
    MyScroll.as
    public function reCreateScrollPane(imagePath2:String):void {
    //imagePath2 = "images/cover.jpg";
    var url:String = "images/"+imagePath2;
    trace(url);
    sp.load(new URLRequest(url));
    trace("scroll pane refreshed");
    sp.addEventListener(ProgressEvent.PROGRESS, progressHandler);
    sp.addEventListener(Event.COMPLETE, completeHandler);
    sp.source = "images/"+imagePath2;
    //sp.source = "images/cover.jpg";
    Can anyone suggest a solution?
    Thanks

    i wonder why i bother with this forum sometimes. i always end
    up answering my own questions an hour later. so the problem was
    that the testes.swf was using a startDrag function and the
    scrollPane in which it resided has its startDrag set to true. i
    guess you can't have both elements dragging at the same time. would
    cause serious upset. so yeah, there you go.

  • How to scroll the content of an XY chart?

    Is it possible to scroll the contents of a chart? I want to keep a fixed Y axis and scroll the X axis. If the chart is placed inside a ScrollPane, then Y axis, legend, and chart title can be scrolled out of the view...

    John,
    thanks for the suggestion. I could find that css selector with the help of a decompiler (most of the chart sources are not yet released). However, to reparent this into a scrollpane required me to subclass the chart. This is because the chart itself is the parent of the content but it does not expose its children (which are protected in the Parent class). The problem is now that the chart does not show. I can only see the title and legend, no axis and no content. What am I doing wrong?
    import javafx.application.Application;
    import javafx.collections.ObservableList;
    import javafx.scene.Node;
    import javafx.scene.Parent;
    import javafx.scene.Scene;
    import javafx.scene.chart.Axis;
    import javafx.scene.chart.LineChart;
    import javafx.scene.chart.NumberAxis;
    import javafx.scene.chart.XYChart;
    import javafx.scene.chart.XYChart.Data;
    import javafx.scene.control.ScrollPane;
    import javafx.stage.Stage;
    public class ScrollableChart extends Application
      public static void main(String[] args)
        Application.launch(args);
      @Override
      public void start(Stage stage) throws Exception
        Parent root;
        MyLineChart chart = createLineChart();   
        if (true)
          // Scroll chart content - does not show chart currently.
          Node chartContent = chart.lookup(".chart-content");
          chart.getChildren().remove(chartContent);
          ScrollPane scroll = new ScrollPane();
          scroll.setContent(chartContent);
          scroll.setFitToHeight(true);
          chart.getChildren().add(scroll);
          root = chart;
        else
          // Scroll chart incl axis etc.
          ScrollPane scroll = new ScrollPane();
          scroll.setContent(chart);
          scroll.setFitToHeight(true);
          root = scroll;
        stage.setScene(new Scene(root, 1024, 768));
        stage.show();   
      public static class MyLineChart extends LineChart<Number,Number> {
        public MyLineChart(Axis<Number> paramAxis, Axis<Number> paramAxis1) { super(paramAxis, paramAxis1); }
        public ObservableList<Node> getChildren() { return super.getChildren(); }
      private MyLineChart createLineChart()
        final int CNT = 500;
        final NumberAxis xAxis = new NumberAxis(), yAxis = new NumberAxis();
        xAxis.setLabel("Number of Month");
        xAxis.setAutoRanging(true);
        final MyLineChart lineChart = new MyLineChart(xAxis, yAxis);
        lineChart.setTitle("Stock Monitoring, 2010");
        XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
        series.setName("My portfolio");
        ObservableList<Data<Number, Number>> data = series.getData();
        for (int i = 1; i <= CNT; i++)
          data.add(new XYChart.Data<Number, Number>(i, 50 * Math.random()));
        lineChart.getData().add(series);
        lineChart.setPrefWidth(CNT * 10);
        return lineChart;
    }

  • Need help scrolling dynamic content from XML

    I am trying to make a photo gallery and I have succeed in
    importing the pictures from XML into Flash. There are still two
    problems:
    1. The content is loading into a movieclip and I tried to
    place a scroll pane on the stage to adding scrolling capabilities.
    I set the parameters to control the movieclip that holds the
    thumbnails but it is not making a scroll bar. I can see the
    pictures inside of the scroll pane but it will not scroll to show
    the rest of the pictures.
    2. I can not figure out how to space the thumbnails evenly. I
    made a variable and multiplied the x position of each picture by it
    but there are large differences between landscape and portrait
    pictures.
    Thanks for the help

    You need to switch from using loadMovie to using the
    MovieClipLoader object. This object has a listener called
    "onLoadInit" that allows you to get the size of your photo when it
    comes in, but before it appears on stage, so that you can adjust
    its placement. Check out the help docs for info on usage.
    WL

  • Moving around in a  j scroll pane.

    I have a JTextArea inside a JScrollPane and I'm trying to get the scroll pane to goto a certain line number that I want by using:
    TA.setCaretPosition(10*linenumber);the linenumber is the line number the user enters and then the 10 is just the pixel it will go down because the interval I counted between each line is about 10. But it doesn't seem to move at all, what am I doing wrong?

    I guess it doesn't work like that.
    What you are doing is moving the caret to a certain position in the document. The setCaretPosition method expects the CHARACTER position in the document to which to move, and has nothing to do with pixels...
    But this won't be moving the scroll pane at all. I think what you are looking for is the TA.scrollRectToVisible(Rectangle) method. You pass a Rectangle on the textarea that you want to be made visible, and the call is repassed to the parents until a JViewPort is found, which is then scrolled.
    To calculate this rectangle you could use TA.getRows() and TA.getSize().height, for example, to determine how much space each row is really occupying.
    Best regards,
    Marcos.

  • Changing the pane content in a swing frame

    hi
    I am now trying to implement a GUI, which consist of a JSplitPane including two JScrollPane-s. The left scroll pane is a JTree and the right should display a sequence of JLabels and JTextFields, depending on the selected tree node on the left.
    I can't figure out how I can change the content of the right scroll pane with each new selection in the tree.
    Here is a part of my code, it seems straightforward, but it displays an EMPTY right JScrollPane.
    Do you have any idea why it is empty?
    NOTE: maskViewPane is my right JScrollPane, which does not display anything!!!
    public void valueChanged(TreeSelectionEvent e) {
            Node node = (Node)tree.getLastSelectedPathComponent();
            if (node == null) return;
            JPanel pane = new JPanel(new GridBagLayout());
                  for(int i = 0; i < labelsVALUES.size(); i++) {
                       JLabel labelComponentI = new JLabel(labelsVALUES.get(i));
                       labels.add(labelComponentI);
                       c.insets = new Insets(15, 15, 0, 30);
                       pane.add(labelComponentI, c);
                       JTextField tfComponentI = new JTextField(TextFieldsVALUES.get(i));
                       textFields.add(tfComponentI);
                       c.insets = new Insets(0, 15, 0, 30);
                       pane.add(tfComponentI, c);
             maskViewPane.removeAll();  //NOTE: maskViewPane is my right JScrollPane, which doesn't display anything
             maskViewPane.setViewportView(pane);
             maskViewPane.repaint();
             this.repaint();
        }

    Let me introduce to to this wonderful place:
    http://forum.java.sun.com/forum.jspa?forumID=57
    :)

Maybe you are looking for

  • How do i get to see websites on full screen so i dont need to keep scrolling left and right?

    before i could see the whole width of a webpage without scrolling left and right but now everything is bigger and i cant see the whole page without scrolling.

  • Performance problem on query

    As part of a large batch process, we load data sent from a client into our systems. The data consists of information representing their organization structure (departments, users etc.). I need to identify all users that are currently in the existing

  • 'Files' tab disapeared

    Not sure how this happened, but in multi-track, I only have the effects tab, the file tab is no longer there. It is in edit mode, just not multi track. How do I get that tab back?

  • Help on ipod plz!!

    I need on my help ipod(gen4 and new) i have connected the wifi on it but it won't let me sign in my imessage it says that it can't help!!!

  • Slowing down after 10.6.8 OSX update

    My MacBook pro has slowed to a crawl since installing 10.6.8 OSX update. Safari really slow, but also switching between applications is a problem. I have not made any changes in my system/hardware around that time. Anyone having this issue?