File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JScrollPand and components Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JScrollPand and components" Watch "JScrollPand and components" New topic

JScrollPand and components

John Galt

Joined: Dec 27, 2002
Posts: 2
I have a JTabbedPane in which new tab are added by reading lines of a file. In each tab I have a JScrollPane with a JTable
Since these are created on the fly I do not know which tab will be selected and therefore must access the JTable by accessing the JScrollPane.
I can access the JScrollPane alright, but do not know how to access the JTable inside this JScrollPane. Any ideas?
John Galt

Joined: Dec 27, 2002
Posts: 2
I have found the solution, but thank you anyway, in case someone else asks the question

JScrollPane jsp = (JScrollPane)displayPane.getComponent(index);
JTable jt = (JTable)jsp.getViewport().getComponent(0);
if there is only one component.
I agree. Here's the link:
subject: JScrollPand and components
It's not a secret anymore!