posted 15 years ago
I have a JScrollPane that at one point in the program can exist inside a JTabbedPane and at other times, exist inside of a JDialog - it gets moved based on user action. I don't know where it is at any given time, I can just get a handle to it (the it being a JScrollPane)
I want to be able to bring whatever the JScrollPane is in, to the front (gain focus??) so the user sees it when some other event occurs. So if it is in a JDialog, I want the dialog to come in front of everything (using modal dialog not an option.) If it is in the JTabbedPane, I want that tab to become selected.
1) How do I tell what the component is currently in (JTabbedPane or JDialog) programmatically and get a proper reference so that I can tell it to gain the focus?
2) What is the best way to "bring it to the front/ gain focus? I know I can use setSelectedCompenent from JTabbedPane and I am not sure on JDialog.
Thanks.