简体   繁体   中英

SWT: Table with cells that span columns

In a Java desktop app with SWT-based GUI, we have a table in which some rows must span multiple columns. This was solved with the approach shown in this official SWT Snippet: Snippet239.java

However, much later it was discovered that there's a major problem with this approach on Ubuntu with the default Ambiance/Radiance theme: There are always vertical lines between the columns, even for cells that span multiple columns. This is shown in the following screenshots:

具有Ambiance / Radiance主题的Ubuntu

具有Clearlooks主题的Ubuntu

As you can see, in the first screenshot there's a vertical line between Column 1 and Column 2. Does anybody have an idea how to get rid of these lines?

We've already tried the following:

  • Table.setLinesVisible(false) : Doesn't work, the vertical lines don't go away.
  • Use owner-draw-based label providers to draw over those vertical lines: Doesn't work, the vertical lines seem to be drawn on top of everything that is drawn by the label providers.
  • Attach paint listener to table to draw over the vertical lines: Doesn't work, because there are lots of glitches whenever the table is scrolled or otherwise updated.
  • The Nebula project has a Grid widget where cells can span multiple columns, and it doesn't have a problem with vertical lines, because the entire table is drawn non-natively. However, we can't justify the effort to replace our table with a Grid widget just to fix the vertical lines problem on a particular platform with certain themes. Also, the Grid widget seems to be a pre-release alpha version.

Based on the things we've already tried, I assume the only way left is to muck around in the platform-specific internals of SWT, but I don't even know where to start with something like that.

我们通过使用具有模拟多个列的单个owner-draw列的Table解决了此问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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