File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JScrollBar Not Moving ViewPort

 
Andrew Cero
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello! Im adding a class I created with 2D graphics called AnimationChartCanvas on to my class AnimationChart. After I added the JScrollBar and move the scroller, it doesn't move the viewport. If anyone could please help me out that would be awesome. Im still a newbie at Java programming .

Here is my code so far: (i think I added extra stuff when I tried calling the JScrollPane stuff).. My code displays the actual scrollbar, but the scrollbar doesn't control the view.


 
Rob Spoor
Sheriff
Pie
Posts: 20388
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please Use Code Tags. You can edit your post to add them.
 
Andrew Cero
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Updated
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> After I added the JScrollBar and move the scroller, it doesn't move the viewport.

if you're talking about this scrollbar
JScrollBar vbar = new JScrollBar(JScrollBar.VERTICAL, 30, 50, 5, 1000);

why would it do anything? (unless you've not posted some of the code)
 
Andrew Cero
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am unfamiliar with the coding for JScrollBar, when the scroll bar moves, do you have to use the actionlistener to get it to move?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JScrollpanes have their own scrollbars

vbar is just a JScrollbar sitting there doing nothing

if you're not seeing the scrollpane's scrollbar,
chart_canvas probably does not have a preferredSize set

try adding this line
chart_canvas.setPreferredSize(new Dimension(1000,1000));

where 1000,1000 is larger than the size of the frame
 
Andrew Cero
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey! It works perfectly. I guess thats the way of setting the Viewport dimensions. Thank you so much for your help.

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic