Hiding a particular cell grid in Jtable

怎甘沉沦 提交于 2019-12-25 04:42:38

问题


I am trying to display numbers in the steps of 5,10,15,20 in a Jtable.

In case of 5 the column names will be 0,5,10,15...
In case of 10 the column names will be 0,10,20,30...
In case of 15 the column names will be 0,15,30,45...
In case of 20 the column names will be 0,20,40,60...

Right now I am able to display 5 and what I need is the same structure but by hiding the vertical cell grid between 5 and 10,15 and 20 and so on.After all this I should remove the column names 5,15,25 and so on.Its not merging columns because my cells are implementing JProgressBar and I need it for painting it in different proportions.Like a cell representing 0-5 may be painted from 0-3 or 3-5 or 2-4.And each cell may be painted based on some value like this.

EDIT::Something similar to Multiple - Span cell as in this link text but my need is merging almost alternate cells by hiding the grid rather than using an Array.Thats why I mentioned it as hiding the vertical border rather than merging the cell.


回答1:


I think the best way to hide what you don't want to see is deleting it.

But If what you want is to hide or make invisible, most of swing components have a method call

setVisible(boolean value)

Here an example how to hide a row(I hope it helps):

http://www.rgagnon.com/javadetails/java-0216.html



来源:https://stackoverflow.com/questions/3598032/hiding-a-particular-cell-grid-in-jtable

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!