Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Table lines
Table lines [message #503689] Tue, 15 December 2009 11:03 Go to next message
Catalin Tileaga is currently offline Catalin TileagaFriend
Messages: 6
Registered: December 2009
Junior Member
I have a table with LinesVisible = true. The line goes after the last column till the end of the table (for rows exactly the same). There is a possibility to hide the line when no column (or row) exists? LinesVisible = false is not a good solution for me.

Thank you in advance,
Catalin
Re: Table lines [message #503739 is a reply to message #503689] Tue, 15 December 2009 15:15 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi Catalin,

No, the native Tables/Trees draw their lines like this, there isn't a way to
influence it. There are a couple of alternatives you can try though:

1. Put a Canvas on top of the Table where you don't want its lines to show,
like in the example snippet below (tried on Windows 2000). The problem in
this scenario occurs when the user resizes the columns, in which case you
have to adjust the Canvas' size in response.

public static void main(String[] args) {
final Display display = new Display();
Shell shell = new Shell(display);
shell.setBounds(200, 200, 400, 400);
shell.setLayout(new FillLayout());
Table table = new Table(shell, SWT.NONE);
table.setLinesVisible(true);
new TableColumn(table, SWT.NONE).setWidth(80);
new TableColumn(table, SWT.NONE).setWidth(80);
new TableColumn(table, SWT.NONE).setWidth(80);
new TableItem(table, SWT.NONE).setText(new String[]
{"one","two","three"});
Canvas canvas = new Canvas(table, SWT.NONE);
canvas.setBackground(table.getBackground());
shell.open();
Rectangle clientArea = table.getClientArea();
canvas.setBounds(240 + 1, 0, clientArea.width - 240 - 1,
clientArea.height);
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
shell.dispose();
display.dispose();
}

2. setLinesVisible(false) and then draw the lines yourself using custom
draw (
http://www.eclipse.org/articles/article.php?file=Article-Cus tomDrawingTableAndTreeItems/index.html )
.. The problem with this approach is that your lines will not look native
(each platform draws their lines differently, and are often influenced by
the user's theme).

HTH,
Grant


"Catalin Tileaga" <tileaga@gmail.com> wrote in message
news:hg7qe2$2ee$1@build.eclipse.org...
> I have a table with LinesVisible = true. The line goes after the last
column till the end of the table (for rows exactly the same). There is a
possibility to hide the line when no column (or row) exists? LinesVisible =
false is not a good solution for me.
>
> Thank you in advance,
> Catalin
Re: Table lines [message #503742 is a reply to message #503739] Tue, 15 December 2009 15:24 Go to previous message
Catalin Tileaga is currently offline Catalin TileagaFriend
Messages: 6
Registered: December 2009
Junior Member
Thank you, Grant. I will try your solutions.

Regards, Catalin
Previous Topic:Render HTML into a StyledText
Next Topic:DnD with a modifier key
Goto Forum:
  


Current Time: Fri Mar 29 12:15:50 GMT 2024

Powered by FUDForum. Page generated in 0.02853 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top