Here's my problem: I'm using a JTable and made my own AbstractTableModel. So far so good. When the text is too long, the cell renderer will truncate the text and show ellipses , but some of my databases registries also have ellipses. Ex: Program Languages I've been studying:

first registry "Visual Basic (2003-2007)"
second registry "C++ (2006-2010)"
third registry "Java (2010-...)"

Means I stopped trying to learn VB in 2007. Stopped C++ in 2010. I'm still learning Java. But when the column is not so large, it will truncate, and sometimes it shows this:

"Visual Basic (2003-..."
"C++ (2006-2010)"
"Java (2010-...)"

The user might get confused, thinking "Visual Basic (2003-..." means "Visual Basic (2003 - ...)" when it should mean "Visual Basic (2003-2007)"

Sorry if I wasn't clear enough, I hope everyone understands, I just want the JTable to truncate the text without the Ellipses.

有帮助吗?

解决方案

This answer shows how the ellipses arise; instead of trying to defeat them, the better approach is to add your JTable to a layout that allows the table to adjust as the enclosing Window is resized. In this example, the table fills BorderLayout.Center, the default for JFrame. For a more appealing initial appearance,

Addendum: Although I don't recommend it from a usability perspective, you can omit the ellipsis in a custom subclass of DefaultTableCellRenderer that uses a custom LabelUI and overrides layoutCL(), as shown here and here.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top