Example usage for javax.swing JViewport getComponents

List of usage examples for javax.swing JViewport getComponents

Introduction

In this page you can find the example usage for javax.swing JViewport getComponents.

Prototype

public Component[] getComponents() 

Source Link

Document

Gets all the components in this container.

Usage

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Vector<Vector<String>> rowData = new Vector<Vector<String>>();
    Vector<String> columnName = new Vector<String>(Arrays.asList("Column 1"));
    for (int i = 0; i < 2000; i++) {
        rowData.add(new Vector<String>(Arrays.asList(Integer.toString(i))));
    }/*from w  w  w  .  j a  va  2 s .c o m*/
    JTable table = new JTable(rowData, columnName);
    JScrollPane scrollPane = new JScrollPane(table);
    JScrollBar vertical = scrollPane.getVerticalScrollBar();
    vertical.setPreferredSize(new Dimension(0, 0));
    f.add(scrollPane);
    f.pack();
    f.setVisible(true);
    JViewport view = scrollPane.getViewport();
    Component[] components = view.getComponents();
    for (int i1 = 0; i1 < components.length; i1++) {
        if (components[i1] instanceof JTable) {
            System.out.println("got");
        }
    }
}