Simple example of Scroll Bar - JavaFX 1.2

ScrollBar - UI Control feature of JavaFX 1.2 .

It has been used in lot of samples but if you are finding it tough to grab out the code from sample to use. Here is a simple(simplest actually :) ) code to use scrollBar. I have create array of rectangle and associated scroll bar with it. Something like this :



And here is the code :

  

package simplescrolluse; import javafx.scene.control.ScrollBar; import javafx.scene.Group; import javafx.scene.paint.Color; import javafx.scene.paint.LinearGradient; import javafx.scene.paint.Stop; import javafx.scene.Scene; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; import javafx.stage.StageStyle; var rect: Rectangle[]; for(i in [0..20]) {     var re = Rectangle {             x: 0             y: 35 \*i  + 28             width: 220, height: 34              fill: LinearGradient {                 startX : 0.0                 startY : 0.0                 endX : 0.0                 endY : 1.0                 stops: [                     Stop {                         color : Color.web("#0174DF")                         offset: 0.0                     },                     Stop {                         color : Color.web("#58ACFA")                         offset: 0.5                     },                     Stop {                         color : Color.web("#0174DF")                         offset: 1.0                     },                 ]             }             opacity: 0.9             stroke: Color.BLACK              strokeWidth: 1            } insert re into rect; } var scroll = ScrollBar {         translateX: bind 240 - 10         translateY: 44         height: 320 - 65         scaleX: 0.5         blockIncrement: 16         clickToPosition: false         min: 0         max: 5         vertical: true     };     var rect_height: Integer = 35;     var contactList: Group = Group {         translateY: bind 0 - scroll.value \* rect_height         content: [ rect ]     } ; Stage {     title: "Simple ScrollBar Use"     width: 240     height: 320     style: StageStyle.UNDECORATED     scene: Scene {         content: [             scroll, contactList         ]     } }

Please let me know if you stuck in any complication with ScrollBar. Actually it looks easy but scroll bar is a complicated thing. Have fun !

 

Comments:

Vaibhav,
Finally a simple example.

Thanks!
-Carl

Posted by Carl on July 29, 2009 at 04:39 PM IST #

:). thank you Carl !

Posted by Vaibhav Choudhary on July 30, 2009 at 06:10 AM IST #

Thanks Vaibhav!!

Posted by Raghav on September 09, 2009 at 01:53 PM IST #

hey nice scroll bar man but what is the part from this example that the scrollbar can drain vertical and horizontal

because i'm new in javafx and i'm looking for a scrollbar horizontal
and those rectangle vertical so opposite from your example

i hope you can help me thanks

Posted by edwin on October 12, 2009 at 08:49 AM IST #

Hi,

This article is nice n informative ... thanks for posting...

but could you just tell me how to increase the size of a bar(the small piece that rolls) inside scroll bar;

Thanks
Nihar

Posted by nihar on October 18, 2009 at 10:27 AM IST #

Thanks very much, I just want to get some examples of scrollBar, and it is .Thanks, I will try to run this sample.

Posted by guest on November 29, 2009 at 05:07 AM IST #

The state's <a href=http://www.mynikeairmax.com/>Nike Air Max</a> decision in October to shrink the school <a href=http://www.mynikeairmax.com/>Air Max </a> year by 10 percent, giving it the fewest number <a href=http://www.mynikeairmax.com/>Air Max 90</a>of instructional days in the nation at 163<a href=http://www.mynikeairmax.com/>Air Max 95</a>, is adding to the already dismal reputation Hawaii's<a href=http://www.mynikeairmax.com/>nike Air Max 95</a> public schools have among<a href=http://www.mynikeairmax.com/>nike Air Max 90</a> servicemen and womenCol. Mike Davino, the director of<a href=http://www.mynikeairmax.com/>Air max ltd </a> manpower, personnel and administration<a href=http://www.mynikeairmax.com/>Air Max shoes </a> for the U.S. Pacific Command, said the truncated school year is yet another concern for officials who have long heard about servicemen and women avoiding Hawaii assignments because of the state's public education system.

Posted by air max on February 01, 2010 at 04:51 AM IST #

The state's <a href=http://www.mynikeairmax.com/>Nike Air Max</a> decision in October to shrink the school <a href=http://www.mynikeairmax.com/>Air Max </a> year by 10 percent, giving it the fewest number <a href=http://www.mynikeairmax.com/>Air Max 90</a>of instructional days in the nation at 163<a href=http://www.mynikeairmax.com/>Air Max 95</a>, is adding to the already dismal reputation Hawaii's<a href=http://www.mynikeairmax.com/>nike Air Max 95</a> public schools have among<a href=http://www.mynikeairmax.com/>nike Air Max 90</a> servicemen and womenCol. Mike Davino, the director of<a href=http://www.mynikeairmax.com/>Air max ltd </a> manpower, personnel and administration<a href=http://www.mynikeairmax.com/>Air Max shoes </a> for the U.S. Pacific Command, said the truncated school year is yet another concern for officials who have long heard about servicemen and women avoiding Hawaii assignments because of the state's public education system.

Posted by air max on February 01, 2010 at 04:58 AM IST #

Christian Louboutin http://www.christianlouboutinmarts.com
Christian Louboutin Shoes http://www.christianlouboutinmarts.com
christian louboutin sale http://www.christianlouboutinmarts.com
Christian Louboutin Boots http://www.christianlouboutinmarts.com
Christian Louboutin Pumps http://www.christianlouboutinmarts.com
Christian Louboutin Sandals http://www.christianlouboutinmarts.com

tiffany wholesale http://www.toptiffanylinks.com
tiffany stores http://www.toptiffanylinks.com
replica tiffany http://www.toptiffanylinks.com
cheap jewelry http://www.toptiffanylinks.com
replica tiffany retail http://www.toptiffanylinks.com
pandora jewelry http://www.toptiffanylinks.com
replica pandora jewelry http://www.toptiffanylinks.com

ed hardy http://www.ed-onlineshop.com
ed hardy clothing http://www.ed-onlineshop.com
ed hardy t shirt http://www.ed-onlineshop.com
ed hardy jeans http://www.ed-onlineshop.com
wholesale ed hardy http://www.ed-onlineshop.com
ed hardy shirt http://www.ed-onlineshop.com
ed hardy boots http://www.ed-onlineshop.com

ed hardy swimwear http://www.edhardydream.com
ed hardy clothing http://www.edhardydream.com
ed hardy clothes http://www.edhardydream.com
ed hardy t shirts http://www.edhardydream.com
ed hardy jeans http://www.edhardydream.com
ed hardy sunglasses http://www.edhardydream.com
ed hardy sunglass http://www.edhardydream.com

nike shox http://www.nikesshox.com
ghd http://www.ghddhair.com
mbt http://www.us-mbt.com

Posted by china wholesale on March 07, 2010 at 01:46 AM IST #

I would like to introduce a very good company, electronic products dealer.
I have bought some products from company,the price was very cheap,and the products are very good quality!They accept paypal, credit card transactions,bank transfers,and more.Just have a look at this web page : http://www.nike-airyeezy.com
I am sure you will could save a lot of money!
Best regards!
web: http://www.victoriawear.com
http://www.homybuy.com

Posted by wwwnice on March 09, 2010 at 06:06 AM IST #

Vaibhav,
Finally a simple example.

Thanks!

Posted by onjerseys on May 11, 2010 at 07:40 AM IST #

Yaaay, THANKS! Thanks for this lovely story, even though it did take quite a long time to read. and have some great contents. Keep up the good work.

Posted by SB Dunks on September 02, 2010 at 03:03 PM IST #

Post a Comment:
Comments are closed for this entry.
About

Hi, I am Vaibhav Choudhary working in Sun. This blog is all about simple concept of Java and JavaFX.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today