Java by API/javax.accessibility/AccessibleTable
AccessibleTable: getAccessibleColumnCount()
import java.awt.Dimension;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleTable;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
public class MainClass extends JFrame {
MainClass() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel p = new JPanel();
p.setPreferredSize(new Dimension(200, 200));
JTable jt = new JTable(10, 3);
p.add(new JScrollPane(jt));
getContentPane().add(p);
pack();
setVisible(true);
}
public static void main(String[] args) {
MainClass ad7 = new MainClass();
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
}
ad7.dumpTableInfo(ad7.getAccessibleContext());
}
void dumpTableInfo(AccessibleContext ac) {
AccessibleTable at = ac.getAccessibleTable();
if (at != null) {
int nCol = at.getAccessibleColumnCount();
System.out.println("Columns = " + nCol);
int nRow = at.getAccessibleRowCount();
System.out.println("Rows = " + nRow);
return;
}
int nChildren = ac.getAccessibleChildrenCount();
for (int i = 0; i < nChildren; i++)
dumpTableInfo(ac.getAccessibleChild(i).getAccessibleContext());
}
}
AccessibleTable: getAccessibleRowCount()
import java.awt.Dimension;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleTable;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
public class MainClass extends JFrame {
MainClass() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel p = new JPanel();
p.setPreferredSize(new Dimension(200, 200));
JTable jt = new JTable(10, 3);
p.add(new JScrollPane(jt));
getContentPane().add(p);
pack();
setVisible(true);
}
public static void main(String[] args) {
MainClass ad7 = new MainClass();
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
}
ad7.dumpTableInfo(ad7.getAccessibleContext());
}
void dumpTableInfo(AccessibleContext ac) {
AccessibleTable at = ac.getAccessibleTable();
if (at != null) {
int nCol = at.getAccessibleColumnCount();
System.out.println("Columns = " + nCol);
int nRow = at.getAccessibleRowCount();
System.out.println("Rows = " + nRow);
return;
}
int nChildren = ac.getAccessibleChildrenCount();
for (int i = 0; i < nChildren; i++)
dumpTableInfo(ac.getAccessibleChild(i).getAccessibleContext());
}
}