Results 1 to 4 of 4
Thread: How to update the scrollbar?
- 06-08-2011, 09:22 AM #1
Member
- Join Date
- Apr 2011
- Posts
- 12
- Rep Power
- 0
How to update the scrollbar?
Hi,
I have a little problem with programming a vertical scroll bar for scrolling a Graphics panel.
At specific moments, the vertical scroll bar is being updated. This is, because a new item is drawn to the panel or an item is removed. As a consequence the height of the panel changes, and so, the vertical scroll bar has to be changed too.
But now I have the following problem. When you, for example, make the frame bigger, the scroll bar should update, but it did not succeed.
How can I update the scroll bar, when the size of the window/panel changes? It is an event. But, what event is that? Is that an event of WindowListener or WindowStateListener? Please help! Thank you in advance!
- 06-08-2011, 09:50 AM #2
Neither. ComponentListener.
But why are you reinventing JScrollPane?
db
- 06-08-2011, 11:54 AM #3
Member
- Join Date
- Apr 2011
- Posts
- 12
- Rep Power
- 0
Hi,
Thanks for the answer.
What do you mean with 'reinventing the wheel'? Is there an easier to build to scroll bar for scrolling graphics?
- 06-08-2011, 06:09 PM #4
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
All you need to manage is the "preferred size" of you panel. Override the getPreferredSize() method to return the proper based based on the items your draw. Whenever you add/remove an item you invoke;Is there an easier to build to scroll bar for scrolling graphics?
on the panel and the layout manager code will look after the scrollbars of the scrollpane. Resizing of the frame will also be handled automatically as well.Java Code:revalidate(); repaint();
Similar Threads
-
Custom scrollbar possible?
By FatWhale in forum AWT / SwingReplies: 2Last Post: 03-19-2011, 02:37 PM -
ScrollBar in a JList
By lupo in forum AWT / SwingReplies: 2Last Post: 05-20-2010, 10:42 PM -
scrollbar issue
By kumar_gemi in forum New To JavaReplies: 9Last Post: 05-06-2009, 06:57 AM -
scrollbar issue
By kumar_gemi in forum NetBeansReplies: 1Last Post: 05-03-2009, 10:23 PM -
Using java.awt.Scrollbar
By Java Tip in forum Java TipReplies: 0Last Post: 01-03-2008, 09:19 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks