This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Looked through the http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JTable.html and the Sun tutorial on JTables, but I could not find a way to do this. I need my attribute names down the side along the first column, not along the top of the first row. The number of rows would always be the same, but as I add records the number of columns would grow. This would need a scroll bar along the bottom rather than along the right side.
Thanks for any suggestions.. --Bob
SCJP - 1.4
SCJD - (B&S) Used 1.5 And It Runs On Solaris10
SCWCD - Thanks to HFSJ!!
This is mainly a matter of working with your JScrollPane and tweaking JTable properties. A JScrollPane is divided into 9 regions, like a tic-tac-toe game, with the center region dominating. When you put a JTable into a JScrollPane, the table itself is displayed in the center region (the viewport), in the center north region your JTable's JTableHeader is displayed, and scroll bars can appear in the center right and bottom center regions. To get what you want (row headers) you need to put a second JTable, containing your row header elements as a single column of data, into the row header view of the JScrollPane. You can also eliminate the column headers from the main table by setting the JScrollPane's column header view to null.