JTable jTable=new JTable();
        for(int i=0;i<jtxm.length;i++) //jtxm为JScrollPane[]
        {
            Object[] com = jtxm[i].getComponents();
            for (int j = 0; j < com.length; j++) {
                if (com[j] instanceof JTable) {
                    jTable = (JTable) com[j];
                }
                int row = jTable.getRowCount();
                JOptionPane.showMessageDialog(null, "表格行数:" + row);
            }
}为何到达不到
if (comJTXM[j] instanceof JTable) {
jTable = (JTable) comJTXM[j];
}

请问如何从JScrollPane中如何取出JTable?

解决方案 »

  1.   

    我知道怎么由你的JTable或者你的JScrollPane,如下
    SwingUtilities.getAncestorOfClass(JScrollPane.class, table);那我想如果要从JScrollPane或者JTable,下面这样??
    SwingUtilities.getAncestorOfClass(JTable.class, jscrollpaneGood luck~
      

  2.   

    SwingUtilities.getAncestorOfClass这个好象是从子对象获取父对象,我是要求从父对象得到子对象