Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » table that allows only one row
table that allows only one row [message #446834] Fri, 03 December 2004 15:28 Go to next message
Eclipse UserFriend
Originally posted by: mikael_focik.hotmail.com

Is it possible to create a table that only allows to add and to display
one row? I would like to have some kind of text field that can show three
values (like a table with three resizable columns), but I only want to
display one row. Is there another control I could use?
TIA, Mikael
Re: table that allows only one row [message #446991 is a reply to message #446834] Tue, 07 December 2004 14:02 Go to previous messageGo to next message
Mani Ghamari is currently offline Mani GhamariFriend
Messages: 33
Registered: July 2009
Member
Hi Mikael,

Why don't you just use a table?
Since you will have to add the table items to the table programmatically,
which is of course done using the constructor:

TableItem(Table parent, int style)

It is always up to you how many rows a table will have.
For example, when the user clicks on the add button (or whatever mechanism
that triggers the updating of table), just check the table for the number of
rows ( using Table.getItemCount() )
if the count is zero, just create the new TableItem. If the count is one,
clear up the table (using Table.removeAll()) and then add the row you want.

As far as I know, there is no control specially designed for that purpose
(It won't make sense, since the same thing is perfectly and easily
implementable using a Table!).
You might consider writing your own widget using a couple of Labels,
Composites and Sashes, yet the same result can be achieved much faster using
the table.

regards,

Mani

"Mikael Focik" <mikael_focik@hotmail.com> wrote in message
news:coq0m6$fq1$1@www.eclipse.org...
> Is it possible to create a table that only allows to add and to display
> one row? I would like to have some kind of text field that can show three
> values (like a table with three resizable columns), but I only want to
> display one row. Is there another control I could use?
> TIA, Mikael
>
Re: table that allows only one row [message #447008 is a reply to message #446991] Tue, 07 December 2004 18:23 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
Actually, a SashForm with a bunch of Text widgets as children will do this
quite easily:

SashForm form = new SashForm(shell, SWT.HORIZONTAL | SWT.SMOOTH);
for (int i = 0; i < 3; i++) {
Text text= new Text(form, SWT.NONE);
text.setText("column "+i);
}

"Mani Ghamari" <mani.ghamari@linkast.com> wrote in message
news:cp4d5m$kh1$1@www.eclipse.org...
> Hi Mikael,
>
> Why don't you just use a table?
> Since you will have to add the table items to the table programmatically,
> which is of course done using the constructor:
>
> TableItem(Table parent, int style)
>
> It is always up to you how many rows a table will have.
> For example, when the user clicks on the add button (or whatever mechanism
> that triggers the updating of table), just check the table for the number
> of rows ( using Table.getItemCount() )
> if the count is zero, just create the new TableItem. If the count is one,
> clear up the table (using Table.removeAll()) and then add the row you
> want.
>
> As far as I know, there is no control specially designed for that purpose
> (It won't make sense, since the same thing is perfectly and easily
> implementable using a Table!).
> You might consider writing your own widget using a couple of Labels,
> Composites and Sashes, yet the same result can be achieved much faster
> using the table.
>
> regards,
>
> Mani
>
> "Mikael Focik" <mikael_focik@hotmail.com> wrote in message
> news:coq0m6$fq1$1@www.eclipse.org...
>> Is it possible to create a table that only allows to add and to display
>> one row? I would like to have some kind of text field that can show three
>> values (like a table with three resizable columns), but I only want to
>> display one row. Is there another control I could use?
>> TIA, Mikael
>>
>
>
Re: table that allows only one row [message #447009 is a reply to message #447008] Tue, 07 December 2004 19:36 Go to previous message
Mani Ghamari is currently offline Mani GhamariFriend
Messages: 33
Registered: July 2009
Member
Yes, About the compsoite, I assumed that there would be a header visible for
each column (so that you have to combine the header AND the Text/Label in a
composite)...

thanks anyways,

Mani

"Veronika Irvine" <veronika_irvine@oti.com> wrote in message
news:cp4sgj$13l$1@www.eclipse.org...
> Actually, a SashForm with a bunch of Text widgets as children will do this
> quite easily:
>
> SashForm form = new SashForm(shell, SWT.HORIZONTAL | SWT.SMOOTH);
> for (int i = 0; i < 3; i++) {
> Text text= new Text(form, SWT.NONE);
> text.setText("column "+i);
> }
>
> "Mani Ghamari" <mani.ghamari@linkast.com> wrote in message
> news:cp4d5m$kh1$1@www.eclipse.org...
>> Hi Mikael,
>>
>> Why don't you just use a table?
>> Since you will have to add the table items to the table programmatically,
>> which is of course done using the constructor:
>>
>> TableItem(Table parent, int style)
>>
>> It is always up to you how many rows a table will have.
>> For example, when the user clicks on the add button (or whatever
>> mechanism that triggers the updating of table), just check the table for
>> the number of rows ( using Table.getItemCount() )
>> if the count is zero, just create the new TableItem. If the count is one,
>> clear up the table (using Table.removeAll()) and then add the row you
>> want.
>>
>> As far as I know, there is no control specially designed for that purpose
>> (It won't make sense, since the same thing is perfectly and easily
>> implementable using a Table!).
>> You might consider writing your own widget using a couple of Labels,
>> Composites and Sashes, yet the same result can be achieved much faster
>> using the table.
>>
>> regards,
>>
>> Mani
>>
>> "Mikael Focik" <mikael_focik@hotmail.com> wrote in message
>> news:coq0m6$fq1$1@www.eclipse.org...
>>> Is it possible to create a table that only allows to add and to display
>>> one row? I would like to have some kind of text field that can show
>>> three values (like a table with three resizable columns), but I only
>>> want to display one row. Is there another control I could use?
>>> TIA, Mikael
>>>
>>
>>
>
>
Previous Topic:ScrolledComposite scrolling versus Canvas scrolling
Next Topic:How to prevent new Shell/Button from gaining focus ?
Goto Forum:
  


Current Time: Thu Apr 25 21:21:14 GMT 2024

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

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

Back to the top