I've been having some issues with a program I have been working on. The main problem is retrieving a component from a container that is in another container. Basically, I have a JTabbedPane container adding a JScrollPane container that contains a JEditorPane or JTextPane component. I already know how to get the component from the tabPane, but when I retrieve the JScrollPane, I need to get the JEditorPane or JTextPane from that retrieved JScrollPane. Below is a snippet of what is going on:
When the user clicks a tab or switches between tabs, it gets the containers and components and also the tab name, but the tab name is retrieved in another method where it's used appropriately. Later on in changeInstance() it assigns that JEditorPane or JTextPane to a variable of it's sort to be used by various methods and such. I've tried looking for a currentEditor.getComponent() method or something like that. I feel as if I'm over thinking, over looking, or under looking for an appropriate method. If anyone has an idea of what do, your help will be much appreciated!Code:protected void changeInstance(ChangeEvent e) {
if(e.getSource() == tabPane){
int selected = tabPane.getSelectedIndex();
Component selectedComponent = tabPane.getComponentAt(selected);
JScrollPane currentEditor = (JScrollPane) selectedComponent;
//Then I take currentEditor and try to retrieve it's component it contains
//This is where I need the assistance.
}
}
Thanks,
Steven
