This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes ensureIndexIsVisible Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "ensureIndexIsVisible" Watch "ensureIndexIsVisible" New topic


Rajesh Radh
Ranch Hand

Joined: Mar 18, 2001
Posts: 35
I am using ensureIndexIsVisible as follows in a constructor. But this does not seems to work. But when I use ensureIndexIsVisible after setVisible(true) in main method, then it works! Why is it like this. In my application, I cannot use JFrame. I have only the liberty to use a JPanel. Therefore I need this method working at place (1). could you please let me know what else I need to do to get this method working at place (1)

Sean MacLean
Ranch Hand

Joined: Nov 07, 2000
Posts: 621
Like a lot of the awt/swing 'objects', many operations don't work until the component is visible. This is related to how they are instantiated and their connection the the native/peer classes. This is from the swing api docs
public void ensureIndexIsVisible(int index)
"Scrolls the viewport to make the specified cell completely visible. Note, for this method to work, the JList must be displayed within a JViewport"
I hope this clears things up a bit.
subject: ensureIndexIsVisible
Similar Threads
Simple JPanel question
using JLabel to title a JScroller
Panel on Splitpane: Fully occupy the Pane
ensureIndexIsVisible() - Please Help