Results 1 to 4 of 4
  1. #1
    stevenfriz is offline Member
    Join Date
    Feb 2012
    Posts
    28
    Rep Power
    0

    Default Retrieving components

    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:

    Java 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.
            }
        }
    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!

    Thanks,
    Steven

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,453
    Rep Power
    20

    Default Re: Retrieving components

    JScrollPane#getViewport()#getView() ?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    stevenfriz is offline Member
    Join Date
    Feb 2012
    Posts
    28
    Rep Power
    0

    Default Re: Retrieving components

    And this returns the component? I will try this. Thanks!

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,453
    Rep Power
    20

    Default Re: Retrieving components

    Moved from New to Java

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Properties: retrieving key-name from value
    By mickylad in forum New To Java
    Replies: 0
    Last Post: 11-12-2011, 02:41 PM
  2. Retrieving html from wicket components
    By BobswYourUcle in forum Web Frameworks
    Replies: 0
    Last Post: 06-28-2011, 06:17 PM
  3. retrieving PK after insertRow()
    By JustinCase in forum JDBC
    Replies: 5
    Last Post: 05-04-2011, 09:47 AM
  4. retrieving Properties
    By bugger in forum New To Java
    Replies: 1
    Last Post: 01-13-2008, 10:44 PM
  5. Retrieving data from the DB
    By yuchuang in forum JDBC
    Replies: 2
    Last Post: 11-27-2007, 09:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •