GeeCON Prague 2014*
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
Author

JScrollPand and components

John Galt
Greenhorn

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
jScrollPane.add(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
Greenhorn

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.
 
GeeCON Prague 2014
 
subject: JScrollPand and components