The Artima Developer Community
Sponsored Link

Java Answers Forum
jscrollpane

1 reply on 1 page. Most recent reply: Jul 15, 2003 9:40 PM by Kishori Sharan

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
jennifer

Posts: 6
Nickname: chil
Registered: Jun, 2003

jscrollpane Posted: Jul 15, 2003 6:56 AM
Reply to this message Reply
Advertisement
hi
I have a scroll pane that I am adding to a panel.This scroll pane has a table on it and the whole scrollpane was passed by a differenct class,so the present gui knows nothing about the table.

I want to be able to get the selected rows from the table but I cant access the table directly,is there any way I could get it via the scrollpane?
Thanks


Kishori Sharan

Posts: 211
Nickname: kishori
Registered: Feb, 2002

Re: jscrollpane Posted: Jul 15, 2003 9:40 PM
Reply to this message Reply
Here is a sample piece of code to get your table reference, which is inside scroll pane. JScrollPane's getViewport().getView() will give you the component inside it. In sample code, testPane is the reference of the JScrollPane.

  
  // Get the viewport of testPane
    JViewport view = testPane.getViewport();
 
    if ( view != null ) {
      // Get the component
      Component c = view.getView();
      // Make sure you have a JTable as view port
      if ( c instanceof JTable ) {
        JTable table = (JTable) c;
        // table is the reference you wanted.
      }
 
    }

Flat View: This topic has 1 reply on 1 page
Topic: reading files Previous Topic   Next Topic Topic: Java Project For $100

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use