This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to set action on scrollpane back (<) and forward (>) button  RSS feed

 
Manu Batham
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
frnds, i want to scroll the records of a table through jscrollpane and show them into the following format in gui --

name : textfield
address : textfield
salary : textfield
mobile no : textfield

i want that as far i move the scrollpane in forward or backward direction, records in the text field should also be changed accordingly, for this i retrieve all the records from table to resultset.type_scroll_insensitive, now how can i built my program so that on clicking on scroll pane, records in textfields changes accordingly. If you hav some confusion in my statement, let me know. thanku
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Get a reference to the horizontal JScrollBar, and attach an AdjustmentListener to it.

Moving to Swing.
 
Manu Batham
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still not able to understand AdjustmentListener, I want to redefine problem if you don't understand it yet, i want a scrollpane attached with a ResultSet, as soon as i move the scrollbar forward, the resultSet.next() method is automatically called to fetch next record.
 
Mikko Kohtamäki
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JScrollPane AdjustmentEvent's are fired from BoundedRangeModel's ChangeListener and the adjustment type returned is always AdjustmentEvent.TRACK and it doesn't fire nothing if the preferred / maximum size is reached by the viewport (value haven't changed).

So AdjustmentListener wont solve your problem...

Maybe creating custom ScrollBarUI extending it from BasicScrollBarUI or some else platform and adding MouseListener to incrButton and decrButton or overriding protected void scrollByUnit(int direction) method (it's called every time even value haven't changed).

I can't figure nothing else for your problem, best of luck...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!