This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
If you add your JTable to a simple JPanel, you'll notice that the table header is absent - you have to add it manually. JTable has special support for JScrollPane for adding the header automatically, but JScrollPane is the only one.
Ankur Sharma wrote:Hi I am using a JList to show a number of data in tabular format.
... Can anyone share an idea how to make first row un-selectable(e.g. like a header in JTable).
It seems like a strange thing to want to do, but try this:You should probably check the ListSelectionModel API to make sure I haven't missed a method.
The other thing you could do is for the first line of your getListCellRendererComponent() method do if (index == 0) isSelected = false; That wouldn't change if the top element could be selected or not, but it would be drawn as unselected even when selected, which is almost as good. It's not as clean, but it may suit your needs.