• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JScrollBar Not Moving ViewPort

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.


 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please Use Code Tags. You can edit your post to add them.
 
Andrew Cero
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Updated
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

reply
    Bookmark Topic Watch Topic
  • New Topic