简体   繁体   English

在Jtable中隐藏特定的单元格

[英]Hiding a particular cell grid in Jtable

I am trying to display numbers in the steps of 5,10,15,20 in a Jtable. 我试图在Jtable中以5、10、15、20的步骤显示数字。

In case of 5 the column names will be 0,5,10,15... 如果为5,则列名将为0、5、10、15 ...
In case of 10 the column names will be 0,10,20,30... 如果为10,则列名称将为0,10,20,30 ...
In case of 15 the column names will be 0,15,30,45... 如果为15,则列名称将为0、15、30、45 ...
In case of 20 the column names will be 0,20,40,60... 如果是20,则列名称将为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. 现在我可以显示5,我需要的是相同的结构,但是要隐藏5和10、15和20之间的垂直单元格网格,依此类推。毕竟,我应该删除列名5,15,25和它不合并列,因为我的单元格正在实现JProgressBar,我需要用它来按不同的比例绘制它,就像一个表示0-5的单元格可以从0-3或3-5或2-4绘制。可能会基于这样的一些值进行绘制。

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. 编辑::类似于此链接文本中的“多跨度”单元格,但是我需要通过隐藏网格而不是使用Array来合并几乎备用的单元格。这就是为什么我提到它隐藏垂直边框而不是合并单元格。

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 但是,如果要隐藏或使它们不可见,则大多数swing组件都有一个方法调用

setVisible(boolean value)

Here an example how to hide a row(I hope it helps): 这是一个如何隐藏行的示例(希望对您有所帮助):

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM