List of usage examples for javax.swing JViewport getComponents
public Component[] getComponents()
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"); } } }