JavaFX 1.3 ListView - control scrollbar

hi any1,
Was looking at the api doc of the new javafx 1.3 listview, i like the new cell attribute. However i couldn't find how to control the scrollbar in the listView.
Reason is trying to use the listView to behave like a message logger to display the latest incoming messages to the user, in my business apps. As such, would need to always move the scrollbar to the latest message.
Is there a way to do this in listView?
Many thanks.

For the record, I recently asked exactly the same question: [How to control ListView display position?|http://forums.sun.com/thread.jspa?threadID=5436800].
So I am not the only one with this need and failing to see a solution...

Similar Messages

  • Is there any event of swip left and swipe right in ListView control ?

    HI
    As in Android phone in call list we can call to some one on right swipe and can message to same person on left swipe. Is it exactly possible in ListView Control for Windows Phone or not?
    Actually I need to get the Swipe left and right Event on these bases I have to download and delete the selected listView item.
    sandeep chauhan

    Hi Sandeep,
    That probably require you to do some extra coding on ManipulationDelta event.
    We can get the initial touch point at from ManipulationStarted while we can get current point from ManipulationDelta, do some calculation we can know whether user swipe left or swipe right.
    --James
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Displaying a SharePoint List in a ListView Control with Grouping by Date

    Dear All
    I have created a ListView to display items from a SharePoint list:
    <asp:ListView ID="UpAndComingEventsLV" runat="server">
    <LayoutTemplate>
    <ul>
    <li id="itemPlaceholder" runat="server" />
    </ul>
    </LayoutTemplate>
    <ItemTemplate>
    <li id="Li1" runat="server">
    <asp:Literal ID="CurrentDate" runat="server" />
    <%#Eval("Title")%> <%#Eval("Event_x0020_Category")%> <%#Eval("EventDate", "{0:HH:mm}")%>
    </li>
    </ItemTemplate>
    </asp:ListView>
    To perform the binding and then display the date I'm doing the following:
    Using oSiteCollection As New SPSite(_ListPath)
    Using web As SPWeb = oSiteCollection.OpenWeb()
    List = web.GetList(_ListPath)
    End Using
    End Using
    Dim Query As New SPQuery
    Query.Query = "<Where><And><Eq><FieldRef Name='Status' /><Value Type='Choice'>Approved</Value></Eq><Geq><FieldRef Name='EventDate' /><Value Type='DateTime'><Today Offset='4' /></Value></Geq></And></Where><OrderBy><FieldRef Name='EventDate' /></OrderBy>"
    'Query.RowLimit = 1
    Query.ViewFields = "<FieldRef Name='Event_x0020_Category' /><FieldRef Name='Title' /><FieldRef Name='EventDate' /></ViewFields>"
    Dim ItemColl As SPListItemCollection = List.GetItems(Query)
    UpAndComingEventsLV.DataSource = ItemColl.GetDataTable
    UpAndComingEventsLV.DataBind()
    dfgdfgfg
    I would like to group my events by date though, rather than display the date against each row. To make things even more complicated, I would like to use friendly names like Today, Tomorrow, Monday, Tuesday instead of dates:
    TODAY
    Event number one
    Event number two
    Event number three
    TOMORROW
    Event number 4
    Event number 5
    MONDAY
    Event number 6
    Event number 7
    At the moment, I've created a ItemDataBound event on the ListView control and I have been able to display the Today, Tomorrow, Monday etc bit but I can't figure out the best way to perform the grouping. Incidentally, I only want to group on the date not
    on time:
    Private Sub UpAndComingEventsLV_ItemDataBound(sender As Object, e As Web.UI.WebControls.ListViewItemEventArgs) Handles UpAndComingEventsLV.ItemDataBound
    If e.Item.ItemType = Web.UI.WebControls.ListViewItemType.DataItem Then
    'Retrieve data item
    Dim DataItem As ListViewDataItem = DirectCast(e.Item, ListViewDataItem)
    Dim RowView As DataRowView = DirectCast(DataItem.DataItem, DataRowView)
    Dim EventDate As DateTime = RowView("EventDate")
    'Get literal control
    Dim CurrentDate As Literal = e.Item.FindControl("CurrentDate")
    'Display friendly date
    If Not IsNothing(CurrentDate) Then
    Select Case EventDate.Date
    Case Is = Now.Date
    CurrentDate.Text = "Today"
    Case Is = Now.Date.AddDays(1)
    CurrentDate.Text = "Tomorrow"
    Case Is = Now.Date.AddDays(2)
    CurrentDate.Text = Now.Date.AddDays(2).DayOfWeek.ToString
    Case Is = Now.Date.AddDays(3)
    CurrentDate.Text = Now.Date.AddDays(3).DayOfWeek.ToString
    Case Is = Now.Date.AddDays(4)
    CurrentDate.Text = Now.Date.AddDays(4).DayOfWeek.ToString
    Case Is = Now.Date.AddDays(5)
    CurrentDate.Text = Now.Date.AddDays(5).DayOfWeek.ToString
    Case Is = Now.Date.AddDays(6)
    CurrentDate.Text = Now.Date.AddDays(6).DayOfWeek.ToString
    End Select
    Else
    CurrentDate.Text = "-"
    End If
    End If
    End Sub
    Please could you help me understand the best way to perform the grouping by date?
    Any help or advice is greatly appreciated!
    Many thanks
    Daniel

    When I've done this in the past I've always used a calculated field that translated the days into the groupings I wanted.  You couldn't do quite the groupings that you list above, but it would give you categories to group on.  You could then
    apply the groupings in the base view.  Then you could use the Row Databound event to change the labels on the Groupings at runtime to the ones you want to use.
    Paul Stork SharePoint Server MVP
    Principal Architect: Blue Chip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

  • Java Swing and windows listview control

    Hi,
    many programming languages have the listview control, to which you can define diferents kinds of data's organizers as Icon, Detail, List, etc.
    Somebody knows if java swing have a component as the listview ?
    thanks

    Yes. It's called JList. Have a look at the tutorial:
    http://java.sun.com/docs/books/tutorial/uiswing/index.html

  • Javafx.scene.control.ScrollBar onMouseEntered Behaviour incorre

    Look at this code:
    def volume:Slider=Slider {
         min: 0.0
         max: 1.0
         value: 0.5
        onMouseEntered: function(MouseEvent):Void{
            //doSomething
          }I would expect, that when I enter the slider, then the action "onMouseEntered" will invoked - but this is not the case, when hover over the slider-button which is indeed a part of the whole slider component.
    The same goes for all mouse/key-events of that component - only the sliders bar without the slider-button (which is definitely a part of the slider) listens to these events.
    Is that a bug or intention? Should I report it to jira?

    I tried a workaround for that case but this does also not work:
    I have put the node slider within a node and define there typical mousevents:
    var mySuperNode:VBox = VBox{
        nodeHPos: HPos.CENTER
        content: [slider]
    // this does not work - mouse entered never be called when hovering over the node "mySuperNode
        onMouseEntered: function(MouseEvent):Void{
            println("why does this not work?");
    Stage {
        width: 400
        height: 150
       scene: Scene {content: mySuperNode}
    }{code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • More String Control Scrollbar Bugs

    In the series of bugs that will never be fixed but need to be posted for the record, here is a variant of the String Control horizontal scrollbar topic.
    Take a String Control (works with Classic, Modern and Silver):
    Show its horizontal scrollbar. That's not an immediate process, so here is the wya it goes in LV 2013:
    - Show Properties
    - Go to the Appearance Tab
    - Uncheck "Wrap at word breaks"
    - Check "Show horizontal scrollbar"
    Here's the result:
    Where's the scrollbar?
    You have to grab one of the control edges, expand it VERTICALLY by one pixel and the container box with then snap to a size that accounts for the scrollbar height:
    Expanding HORIZONTALLY has no effect:
    If you try that with the System String Control, similar limitations apply but you get a bonus:
    The one pixel tall string!

    X. wrote:
    That is probably a good guess. However, I would argue that if I go throught the trouble of opening the Properties Panel to ask for a horizontal scrollbar, I'd be happy to get the scrollbar added.
    I have actually found out another oddity (which makes the behavior of the System String somewhat less outlandish):
    If you take the default Silver String control, which has a height of 37 pixels, and expands it to 39 pixels or more, then following the procedure I described in my original post, the horizontal scollbar will be shown.
    Like this:
    Here I have painted the String background in red so that you can see that a 1 or 2 pixel string display area is available (like I described for the System string, but here, if you further manipulate the control, it will snap to a more reasonable height allowing you to type in something visible).
    So, what I am saying is that there is not much coherence in what the algorithm considers a valid condition to show a scrollbar. Of course all this becomes very interesting when the font size is changed...
    Well, you just illustrated exactly what I meant.  The scroll bar is as tall as the control itself is.  I think it is unavoidable though.  Just look at everything that has a scroll bar.  The scroll bar gets added to the INSIDE of the window that needs it, not the outside.
    Bill
    (Mid-Level minion.)
    My support system ensures that I don't look totally incompetent.
    Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

  • JavaFX 1.2, ListView, is it possible to have an event when an item is sel?

    I have a listview, in it contains a lot of text in the format of "abcd -> efgh". When the user selects any item in the ListView, I need two textboxes to populate, one with "abcd" and the other with "efgh". Any thoughts?
    I'm using NetBeans6.8 and JavaFX 1.2. Moving to 1.3 is not an option, so let me know if this can be done :)
    Thanks!
    Andy

    Now I guess I'm still confused on one thing. Where should this code go exactly? I wrote the following:
            //Bind the selected index of the Component Catalog in order to populate the textboxes
            var compCatalogSelectedIndex = bind compCatalogListView.selectedItem on replace {
                def myItem = compCatalogSelectedIndex as String;
                var separator = "->";
                var mapping:String[] = myItem.split(separator);
                //Set component side
                componentTextBox.text = mapping[0];
                //Set catalog side
                catalogTextBox.text = mapping[1];
            }I threw a breakpoint in there and it's not reaching it when I change the index.

  • Table control scrollbar

    How to make scrollbar(Vertical)  IN tablecontrol.

    hi,
    in the screen , when we create the table control
    there is a option for 'resizing'.
    there tick both vertical and horzontal.
    just right this code in the PBO.
    *when we write the blow code in PBO, the scroll bar will come dynamically.
    'int_factor' is the internal table.
    *number of lines of table control
      DESCRIBE TABLE int_factor LINES wf_lines.
      tab_control-lines = wf_lines + 1.
    hope this will help u.
    for any clarifiaction pls mail me.
    pls reward points, if this helped u.
    regards,
    anversha.
    [email protected]

  • ListView Control - How Take Data Out of One ListView Control and Put It Into Another ListView Control Please Help

    Public Class Form1
    'Also Let Me Note - I will actually only want to move an item from lvOriginalList if the PersonAge is (lets say) '21
        'I have a ListView named
        ' lvOriginalList
        'It has the Following Columns
        ' IDNumber
        ' PersonName
        ' PersonAge
        'I have a Second ListView named
        ' lvRemovedList
        'It has the Following Columns
        ' IDNumber
        ' PersonName
        ' PersonAge
        'What I am attempting to do is read a row out of the first listview
        'Compare the IDNUmber, PersonName and PersonAge from out of it (lvOriginalList)
        'And If the Information is not present in the second ListView (lvRemoved) then Move it to it
        'And then Remove that Row from the First one (lvOriginalList)
        'What I have tried:
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            'Populate lvOriginalList with Test Data
            Dim FileNum As Integer = FreeFile()
            Dim lvOriginalListCounter As Integer = 0
            FileOpen(FileNum, "d:\testdata\alphadata.txt", OpenMode.Input)
            lvOriginalList.Items.Clear()
            Do While Not EOF(FileNum)
                Dim OriginalIDNumber As String = ""
                Dim OriginalPersonName As String = ""
                Dim OriginalPersonAge As String = ""
                OriginalIDNumber = LineInput(FileNum)
                OriginalPersonName = LineInput(FileNum)
                OriginalPersonAge = LineInput(FileNum) 
                lvOriginalList.Items.Add(OriginalIDNumber, lvOriginalListCounter)
                lvOriginalList.Items(lvOriginalListCounter).SubItems.Add(OriginalPersonName)
                lvOriginalList.Items(lvOriginalListCounter).SubItems.Add(OriginalPersonAge) 
                lvOriginalListCounter = lvOriginalListCounter + 1
            Loop
            FileClose(FileNum)
        End Sub
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim OriginalIDNumber As String = ""
            Dim OriginalPersonName As String = ""
            Dim OriginalPersonAge As String = ""
            Dim CompareIDNumber As String = ""
            Dim ComparePersonName As String = ""
            Dim ComparePersonAge As String = ""
            Dim NumlvRemovedListItems As Integer = 0
            Dim CompareCounter As Integer = 0
            For Each item As ListViewItem In Me.lvOriginalList.Items
                '1  -   Get A Row Out of lvOriginalList
                OriginalIDNumber = item.Text
                OriginalPersonName = item.SubItems.Item(1).Text
                OriginalPersonAge = item.SubItems.Item(2).Text
                '2  -   Check To See If That Person Is Already  in lvRemovedList
                'Have to check to see if the lvRemovedList list Box is Empty
                NumlvRemovedListItems = lvRemovedList.Items.Count
                If NumlvRemovedListItems = 0 Then
                    'the lvRemovedList listbox is empty
                    'so add That Person as the first entry into the list box (lvRemovedList)
                    lvRemovedList.Items.Add(OriginalIDNumber, NumlvRemovedListItems)
                    lvRemovedList.Items(NumlvRemovedListItems).SubItems.Add(OriginalPersonName)
                    lvRemovedList.Items(NumlvRemovedListItems).SubItems.Add(OriginalPersonAge)
                    'then remove the player from the lvPlayerList listbox
                    item.Remove()
                Else
                    For Each itemb As ListViewItem In Me.lvRemovedList.Items
                        CompareIDNumber = item.Text
                        ComparePersonName = item.SubItems.Item(1).Text
                        ComparePersonAge = item.SubItems.Item(2).Text
                        If OriginalPersonName = ComparePersonName Then
                            'do nothing that persons name is already in the lvRemovedList list
                        Else
                            'do this because the player is not already in a matchin the lvRemovedList list
                            lvRemovedList.Items.Add(CompareIDNumber, CompareCounter)
                            lvRemovedList.Items(CompareCounter).SubItems.Add(ComparePersonName)
                            lvRemovedList.Items(CompareCounter).SubItems.Add(ComparePersonAge)
                        End If
                    Next
                End If
                CompareCounter = CompareCounter + 1
            Next
        End Sub
    End Class
    'So what Am I doing Wrong
    'It is only Removing the First entry out of lvOriginalList (but at least the remaining data is still there and the empty Row is removed)
    'And only That first Entry is Appearing in lvRemovedList
    'Please Help

    Hello,
    I have created a simple sample, you could focus on the button click event and edit it to fit your requirements by yourself.
    Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    With ListView1
    .View = View.Details
    With .Columns
    .Add("IDNumber")
    .Add("PersonName")
    .Add("PersonAge")
    End With
    With .Items
    For index = 20 To 33
    .Add("ID" & index, index - 19)
    With ListView1.Items(.Count - 1).SubItems
    .Add("Name" & index)
    .Add(index)
    End With
    Next
    End With
    End With
    With ListView2
    .View = View.Details
    With .Columns
    .Add("IDNumber")
    .Add("PersonName")
    .Add("PersonAge")
    End With
    With .Items
    For index = 21 To 22
    .Add("ID" & index, index - 19)
    With ListView2.Items(.Count - 1).SubItems
    .Add("Name" & index)
    .Add(index)
    End With
    Next
    End With
    End With
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    For Each item As ListViewItem In ListView1.Items
    If CInt(item.SubItems(2).Text) < 29 Then
    item.Remove()
    Dim blContain As Boolean = False
    For Each item2 In ListView2.Items
    If item2.Text.ToString().Equals(item.Text.ToString()) Then
    blContain = True
    'Exit For
    End If
    Next
    If Not blContain Then
    ListView2.Items.Add(item)
    End If
    End If
    Next
    End Sub
    End Class
    Result.
    Regards,
    Carl
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Controlling scrollbars and container sizes

    We are having this exact problem. This is a pretty crazy
    problem. It seems like inner containers are not "pushing" the outer
    containers out far enough. The only resolution that I can find is
    to set a bunch of static sizes for containers, but then we lose the
    flexibility. Any ideas? The scrollbars are ridiculous cause they
    are constantly getting cut off by the browser or are there when
    they shouldn't be. Is there a better way for apps with multiple
    layers that are larger than the normal height of a screen?

    Thanks Jake,
    Reducing containers is surely a good thing. Unfortunately the
    application I'm working on is pretty large and at places there are
    easily between 5 and 10 nested containers. I'm not using
    AbsoluteLayout though and mostly a combination of HBox/VBox/Forms.
    One problem I ran into is with the use of HDividedBox, which
    when resizing caused its children to contain double scrollbars. The
    child would have a scrollbar and one of the child's children would
    have a scrollbar. If you get small enough then the parent also has
    a scrollbar. It ain't a pretty picture.
    Sofar I've found that HDividedBox has a problem with resizing
    a child component if that child is a container holding more
    components/containers. Its difficult to debug but my impression is
    that when the layout manager pass takes place, the child
    container's size hasn't been updated yet. As a result the deeper
    level is set larger than it should, causing an extra scrollbar.
    My workaround (bit hack) that helped somewhat is to catch the
    resize event in the HDividedBox child and set its minWidth to be
    the max of the measuredMinWidth of the child's children. This only
    affects how HDividedBox resizes its child, and isn't a general
    solution unfortunately.
    For those interested:
    eg:
    quote:
    function onResize(event:Event):void
    if ((child1 != null) && (child2 != null))
    this.minWidth = Math.max( child1.measuredMinWidth,
    child2.measuredMinWidth);

  • Listview control

    I want to add a Excel like filter to a ListView in a powershell form.
    The end user would like the ability to sift through the data selectively instead of looking at a few hundred rows at a time.
    The source data is from a SQL server table Employee Name, Department, Location.
    Any help is appreciated.

    Thanks JNV for the response.
    Instead of creating each object in the listview, I tie up the query directly to the listview.
    Is that what you are asking me to do? I am beginning to learn powershell, so help me of the starting blocks.
    The ListView needs a dataset of some kind since it has no immediate filter methods.  A DataTable has a filter that can be set.
    You can create a DataTable object and add the data then filter or sort it much easier than trying to manage the data as a collection (ArrayList).
    An ArrayList can also be filtered but may need extra bits.
    ¯\_(ツ)_/¯

  • TABSTRIP control scrollbar

    Hi all
    I have on screen window with TABSTRIPS and when I have a smaller resolution then I see on the right scrollbar. Is is possible
    to change position for this from code like in ALV grid->set_scroll_info_via_id ?
    Thanx for any help
    Edited by: Kosmo on Jan 28, 2010 9:23 AM

    Do you know procedure to change position with scrollbar to main window with tabstrip?

  • JavaFX ListView with pagination capability?

    Does anyone know of an example of steer me in the right direction of how to implement pagination on a ListView control in JavaFX? I need the scroll bar functionality as well.

    PaginatedTableView control has an example of a TableView with pagination. The basic idea should be pretty similar.

  • ScrollBar visibleAmountProperty JavaFX 2.1.1 and 2.2.0-beta

    Hi,
    I'm new to JavaFX. I tried the JavaFX examples provided by Oracle. In the Ensemble.jar there is an example called "Display Shelf" where several images are loaded and at the bottom you can see a scrollbar.
    I have a question to the setVisibleAmount method of a ScrollBar. If I understood properly, the visibleAmountProperty specifies the size of the scroll bar's thumb. When I start the "Display Shelf" example with only 2 images (see the code below), the thumb of the scrollbar fills the complete scrollbar. My expectation was that the thumb only fills half of the available space. That is the reason why I played with the visibleAmountProperty and found out that scrollBar.setVisibleAmount(0.5) works fine for 2 images. But I don't understand why and how this property works. My understanding was:
    If I load 2 images and setVisibleAmount is set to 1, the size of the thumb should be 1/2 of the scrollbar's size;
    if I load 14 images and setVisibleAmount is set to 1, the size of the thumb should be 1/14 of the scrollbar's size.
    If I set the visibleAmountProperty to 0, I understand that the thumb's size is not adjusted. But I don't want to use 0 because it is too small for my application. The thumb's size should be adjusted depending on the number of loaded images.
    Can you explain me how setVisibleAmount works and to which value it should be set? (Is there a bug?)
    Here is the slightly modified "Display Shelf" example:
    * Copyright (c) 2008, 2012 Oracle and/or its affiliates.
    * All rights reserved. Use is subject to license terms.
    import javafx.application.Application;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.stage.Stage;
    import javafx.animation.Interpolator;
    import javafx.animation.KeyFrame;
    import javafx.animation.KeyValue;
    import javafx.animation.Timeline;
    import javafx.beans.InvalidationListener;
    import javafx.beans.Observable;
    import javafx.beans.property.DoubleProperty;
    import javafx.beans.property.SimpleDoubleProperty;
    import javafx.collections.ObservableList;
    import javafx.event.EventHandler;
    import javafx.scene.Group;
    import javafx.scene.Parent;
    import javafx.scene.control.ScrollBar;
    import javafx.scene.effect.PerspectiveTransform;
    import javafx.scene.effect.ReflectionBuilder;
    import javafx.scene.image.Image;
    import javafx.scene.image.ImageView;
    import javafx.scene.input.KeyCode;
    import javafx.scene.input.KeyEvent;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.layout.Region;
    import javafx.scene.shape.Rectangle;
    import javafx.util.Duration;
    * A display shelf of images using the PerspectiveTransform effect.
    * @see javafx.scene.effect.PerspectiveTransform
    * @see javafx.scene.effect.Reflection
    * @see javafx.scene.control.ScrollBar
    * @see javafx.scene.input.MouseEvent
    * @see javafx.scene.input.KeyEvent
    * @resource animal1.jpg
    * @resource animal2.jpg
    * @resource animal3.jpg
    * @resource animal4.jpg
    * @resource animal5.jpg
    * @resource animal6.jpg
    * @resource animal7.jpg
    * @resource animal8.jpg
    * @resource animal9.jpg
    * @resource animal10.jpg
    * @resource animal11.jpg
    * @resource animal12.jpg
    * @resource animal13.jpg
    * @resource animal14.jpg
    public class DisplayShelfSample extends Application {
        private static final double WIDTH = 450, HEIGHT = 300;
        private void init(Stage primaryStage) {
            Group root = new Group();
            primaryStage.setResizable(false);
            primaryStage.setScene(new Scene(root, 495,300));
            // load images
    //        Image[] images = new Image[14];
    //        for (int i = 0; i < 14; i++) {
    //            images[i] = new Image( DisplayShelfSample.class.getResource("animal"+(i+1)+".jpg").toExternalForm(),false);
    /*start of my modification: load only 2 images instead of 14*/
            Class<DisplayShelfSample> clazz = DisplayShelfSample.class;
            ClassLoader cl = clazz.getClassLoader();
            Image[] images = new Image[2];
            for (int i = 0; i < 2; i++) {
                images[i] = new Image(cl.getResource("smallimage"+(i+1)+".jpg").toExternalForm(),false);
    /*end of my modification*/
            // create display shelf
            DisplayShelf displayShelf = new DisplayShelf(images);
            displayShelf.setPrefSize(WIDTH, HEIGHT);
            root.getChildren().add(displayShelf);
         * A ui control which displays a browsable display shelf of images
        public static class DisplayShelf extends Region {
            private static final Duration DURATION = Duration.millis(500);
            private static final Interpolator INTERPOLATOR = Interpolator.EASE_BOTH;
            private static final double SPACING = 50;
            private static final double LEFT_OFFSET = -110;
            private static final double RIGHT_OFFSET = 110;
            private static final double SCALE_SMALL = 0.7;
            private PerspectiveImage[] items;
            private Group centered = new Group();
            private Group left = new Group();
            private Group center = new Group();
            private Group right = new Group();
            private int centerIndex = 0;
            private Timeline timeline;
            private ScrollBar scrollBar = new ScrollBar();
            private boolean localChange = false;
            private Rectangle clip = new Rectangle();
            public DisplayShelf(Image[] images) {
                // set clip
                setClip(clip);
                // set background gradient using css
                setStyle("-fx-background-color: linear-gradient(to bottom," +
                        " black 60, #141414 60.1%, black 100%);");
                // style scroll bar color
                scrollBar.setStyle("-fx-base: #202020; -fx-background: #202020;");
                // create items
                items = new PerspectiveImage[images.length];
                for (int i=0; i<images.length; i++) {
                    final PerspectiveImage item =
                            items[i] = new PerspectiveImage(images);
    final double index = i;
    item.setOnMouseClicked(new EventHandler<MouseEvent>() {
    public void handle(MouseEvent me) {
    localChange = true;
    scrollBar.setValue(index);
    localChange = false;
    shiftToCenter(item);
    // setup scroll bar
    scrollBar.setMax(items.length-1);
    scrollBar.setVisibleAmount(0.5);
    scrollBar.setUnitIncrement(1);
    scrollBar.setBlockIncrement(1);
    scrollBar.valueProperty().addListener(new InvalidationListener() {
    public void invalidated(Observable ov) {
    if(!localChange)
    shiftToCenter(items[(int)scrollBar.getValue()]);
    // create content
    centered.getChildren().addAll(left, right, center);
    getChildren().addAll(centered,scrollBar);
    // listen for keyboard events
    setFocusTraversable(true);
    setOnKeyPressed(new EventHandler<KeyEvent>() {
    public void handle(KeyEvent ke) {
    if (ke.getCode() == KeyCode.LEFT) {
    shift(1);
    localChange = true;
    scrollBar.setValue(centerIndex);
    localChange = false;
    } else if (ke.getCode() == KeyCode.RIGHT) {
    shift(-1);
    localChange = true;
    scrollBar.setValue(centerIndex);
    localChange = false;
    // update
    update();
    @Override protected void layoutChildren() {
    // update clip to our size
    clip.setWidth(getWidth());
    clip.setHeight(getHeight());
    // keep centered centered
    centered.setLayoutY((getHeight() - PerspectiveImage.HEIGHT) / 2);
    centered.setLayoutX((getWidth() - PerspectiveImage.WIDTH) / 2);
    // position scroll bar at bottom
    scrollBar.setLayoutX(10);
    scrollBar.setLayoutY(getHeight()-25);
    scrollBar.resize(getWidth()-20,15);
    private void update() {
    // move items to new homes in groups
    left.getChildren().clear();
    center.getChildren().clear();
    right.getChildren().clear();
    for (int i = 0; i < centerIndex; i++) {
    left.getChildren().add(items[i]);
    center.getChildren().add(items[centerIndex]);
    for (int i = items.length - 1; i > centerIndex; i--) {
    right.getChildren().add(items[i]);
    // stop old timeline if there is one running
    if (timeline!=null) timeline.stop();
    // create timeline to animate to new positions
    timeline = new Timeline();
    // add keyframes for left items
    final ObservableList<KeyFrame> keyFrames = timeline.getKeyFrames();
    for (int i = 0; i < left.getChildren().size(); i++) {
    final PerspectiveImage it = items[i];
    double newX = -left.getChildren().size() *
    SPACING + SPACING * i + LEFT_OFFSET;
    keyFrames.add(new KeyFrame(DURATION,
    new KeyValue(it.translateXProperty(), newX, INTERPOLATOR),
    new KeyValue(it.scaleXProperty(), SCALE_SMALL, INTERPOLATOR),
    new KeyValue(it.scaleYProperty(), SCALE_SMALL, INTERPOLATOR),
    new KeyValue(it.angle, 45.0, INTERPOLATOR)));
    // add keyframe for center item
    final PerspectiveImage centerItem = items[centerIndex];
    keyFrames.add(new KeyFrame(DURATION,
    new KeyValue(centerItem.translateXProperty(), 0, INTERPOLATOR),
    new KeyValue(centerItem.scaleXProperty(), 1.0, INTERPOLATOR),
    new KeyValue(centerItem.scaleYProperty(), 1.0, INTERPOLATOR),
    new KeyValue(centerItem.angle, 90.0, INTERPOLATOR)));
    // add keyframes for right items
    for (int i = 0; i < right.getChildren().size(); i++) {
    final PerspectiveImage it = items[items.length - i - 1];
    final double newX = right.getChildren().size() *
    SPACING - SPACING * i + RIGHT_OFFSET;
    keyFrames.add(new KeyFrame(DURATION,
    new KeyValue(it.translateXProperty(), newX, INTERPOLATOR),
    new KeyValue(it.scaleXProperty(), SCALE_SMALL, INTERPOLATOR),
    new KeyValue(it.scaleYProperty(), SCALE_SMALL, INTERPOLATOR),
    new KeyValue(it.angle, 135.0, INTERPOLATOR)));
    // play animation
    timeline.play();
    private void shiftToCenter(PerspectiveImage item) {
    for (int i = 0; i < left.getChildren().size(); i++) {
    if (left.getChildren().get(i) == item) {
    int shiftAmount = left.getChildren().size() - i;
    shift(shiftAmount);
    return;
    if (center.getChildren().get(0) == item) {
    return;
    for (int i = 0; i < right.getChildren().size(); i++) {
    if (right.getChildren().get(i) == item) {
    int shiftAmount = -(right.getChildren().size() - i);
    shift(shiftAmount);
    return;
    public void shift(int shiftAmount) {
    if (centerIndex <= 0 && shiftAmount > 0) return;
    if (centerIndex >= items.length - 1 && shiftAmount < 0) return;
    centerIndex -= shiftAmount;
    update();
    * A Node that displays a image with some 2.5D perspective rotation around the Y axis.
    public static class PerspectiveImage extends Parent {
    private static final double REFLECTION_SIZE = 0.25;
    private static final double WIDTH = 200;
    private static final double HEIGHT = WIDTH + (WIDTH*REFLECTION_SIZE);
    private static final double RADIUS_H = WIDTH / 2;
    private static final double BACK = WIDTH / 10;
    private PerspectiveTransform transform = new PerspectiveTransform();
    /** Angle Property */
    private final DoubleProperty angle = new SimpleDoubleProperty(45) {
    @Override protected void invalidated() {
    // when angle changes calculate new transform
    double lx = (RADIUS_H - Math.sin(Math.toRadians(angle.get())) * RADIUS_H - 1);
    double rx = (RADIUS_H + Math.sin(Math.toRadians(angle.get())) * RADIUS_H + 1);
    double uly = (-Math.cos(Math.toRadians(angle.get())) * BACK);
    double ury = -uly;
    transform.setUlx(lx);
    transform.setUly(uly);
    transform.setUrx(rx);
    transform.setUry(ury);
    transform.setLrx(rx);
    transform.setLry(HEIGHT + uly);
    transform.setLlx(lx);
    transform.setLly(HEIGHT + ury);
    public final double getAngle() { return angle.getValue(); }
    public final void setAngle(double value) { angle.setValue(value); }
    public final DoubleProperty angleModel() { return angle; }
    public PerspectiveImage(Image image) {
    ImageView imageView = new ImageView(image);
    imageView.setEffect(ReflectionBuilder.create().fraction(REFLECTION_SIZE).build());
    setEffect(transform);
    getChildren().addAll(imageView);
    public double getSampleWidth() { return 495; }
    public double getSampleHeight() { return 300; }
    @Override public void start(Stage primaryStage) throws Exception {
    init(primaryStage);
    primaryStage.show();
    public static void main(String[] args) { launch(args); }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  

    Hi Kaylee,
    From my point of view, the Official Oracle example have 2 bugs. First of all use truncate: http://mindprod.com/jgloss/round.html#TRUNCATE to get the value and then the behaviour its not correct. This is the code of the example: shiftToCenter(items[(int)scrollBar.getValue()]); And the results would be (with just 3 images):
    Scrollbar range: 0 - 2
    Images values: 0, 1, 2
    Scrollbar value: 0.0 shiftToCenterValue:0
    Scrollbar value: 0.4 shiftToCenterValue:0
    Scrollbar value: 0.5 shiftToCenterValue:0
    Scrollbar value: 0.9 shiftToCenterValue:0
    Scrollbar value: 1.0 shiftToCenterValue:1
    Scrollbar value: 1.4 shiftToCenterValue:1
    Scrollbar value: 1.5 shiftToCenterValue:1
    Scrollbar value: 1.9 shiftToCenterValue:1
    Scrollbar value: 2.0 shiftToCenterValue:2
    So the ranges are:
    Image 0: 0,0 - 0,999
    Image 1: 1,0-1,999
    Image 2: 2,0
    If we rounded the value:  shiftToCenter(items[(int)(scrollBar.getValue()+0.5)]); (there are different ways to round a value, this is the fastest one)
    Scrollbar value: 0.0 shiftToCenterValue:0
    Scrollbar value: 0.4 shiftToCenterValue:0
    Scrollbar value: 0.5 shiftToCenterValue:1
    Scrollbar value: 0.9 shiftToCenterValue:1
    Scrollbar value: 1.0 shiftToCenterValue:1
    Scrollbar value: 1.4 shiftToCenterValue:1
    Scrollbar value: 1.5 shiftToCenterValue:2
    Scrollbar value: 1.9 shiftToCenterValue:2
    Scrollbar value: 2.0 shiftToCenterValue:2
    So the ranges are:
    Image 0: 0,0 - 0,4999
    Image 1: 0,5-1,4999
    Image 2: 1,5-2,0
    Much better. But there is also another error, and this if the one that will let you show just 2 images. Change the code: scrollBar.setVisibleAmount(0.5); to scrollBar.setVisibleAmount(1); and then it doesn't deppend on the number of images it always let you navigate through the images. With 10 iamges works, and with 2 images too.
    Maybe the JavaFx team could change these two errors on their example.
    Have a nice week.
    Edited by: ciruman on 06.08.2012 00:41
    Edited by: ciruman on 06.08.2012 00:47

  • Scrollbar in Tree Control = wonky

    The TREE control scrollbar seems to have some ill-thought-out behavior.
    1... Run the example TREE ENHANCEMENTS (Examples - Building UIs - Displaying Data - General )
    2... Choose a folder on your machine with a few (3-5) folders in it but lots of files and folders contained within those folders.
    3... Select the PATTERN as appropriate.
    4... Run the VI.  Your files should show up in the list, then the list collapses.
    5... Expand the folders, so that there are more items in the list than it can display at one time.
    6... The scrollbar appears (that's sensible).
    7... Scroll down so that items disappear off the top.
    8... Right click and choose CLOSE ALL ITEMS
    --- I would expect the control to automatically move back up to the top, so you could see something, but it doesn't.
    9... Play with the scrollbar thumb.  Not exactly sensible.
    Here is a JING to watch, showing this behavior.
    The code that populates this tree is copied from the example (and modified to remove file extensions).
    Once the tree is populated, the code is doing nothing (except waiting for a QUIT button).
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

    Just run the example I mentioned.  It's not code that does it - it's the behavior of the tree control itself.
    But you need to structure the folders so that you have a few (< # lines in tree) root-level folders, and many (> #lines in tree) sub-folders/files, whatever.
    When you collapse the tree, I would expect the scrollbar to adapt to the new situation, and possibly disappear.  Instead, it's working on old information, I suppose.
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

Maybe you are looking for