JTable table = new JTable(data, columnNames); Rectangle cellRect = table.getCellRect(2, 3, false);
JTable table = new JTable(data, columnNames); Rectangle cellRect = table.getCellRect(0, 0, true); int x = cellRect.x; int y = cellRect.y; int width = cellRect.width; int height = cellRect.height;In this example, a JTable is created with the specified data and column names. The getCellRect method is then called to retrieve the bounding rectangle of the cell at row 0 and column 0. The `true` parameter specifies that the rectangle should include the table's header. The x, y, width, and height properties of the resulting rectangle are then assigned to separate variables for further use. The javax.swing package library includes the JTable class along with other GUI components for Java Swing applications.