Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Strange problem with SWT tables ...
Strange problem with SWT tables ... [message #450885] |
Sat, 19 February 2005 18:22 |
Eclipse User |
|
|
|
Originally posted by: hs.cybertec.at
I have used SWT for a long time now.
Today, we encountered a problem we have never seen before.
We are using a simple SQL statement to build a table. The problem is
that only the first column is actually filled with data.
Does anybody know why? I am using Eclipse 3.0.0.
Here is the code:
Table table;
table = new Table(shell, SWT.BORDER);
table.setBounds(10, 15, 845, 370);
table.setLinesVisible(true);
table.setHeaderVisible(true);
fillBaseTable();
final TableColumn v_nr = new TableColumn(table, SWT.NONE);
v_nr.setWidth(39);
v_nr.setText("Nr.");
final TableColumn v_datum = new TableColumn(table, SWT.NONE);
v_datum.setWidth(91);
v_datum.setText("Datum");
final TableColumn v_beleg = new TableColumn(table, SWT.NONE);
v_beleg.setWidth(77);
v_beleg.setText("BelegNr");
final TableColumn v_soll = new TableColumn(table, SWT.NONE);
v_soll.setWidth(70);
v_soll.setText("Soll");
final TableColumn v_haben = new TableColumn(table, SWT.NONE);
v_haben.setWidth(70);
v_haben.setText("Haben");
final TableColumn v_betrag = new TableColumn(table, SWT.NONE);
v_betrag.setWidth(80);
v_betrag.setText("Betrag");
final TableColumn v_ust = new TableColumn(table, SWT.NONE);
v_ust.setWidth(137);
v_ust.setText("Ust.");
final TableColumn v_text = new TableColumn(table, SWT.NONE);
v_text.setWidth(100);
v_text.setText("Text");
public void fillBaseTable()
{
String sql = "SELECT id, tstamp::text, belegnt, sollbuch,
habenbuch, betrag, beschreibung "
+ " FROM t_buchung "
+ " ORDER BY id, tstamp, sollbuch, habenbuch ";
try
{
table.removeAll();
Statement stmt = Config.conn.createStatement();
ResultSet res = stmt.executeQuery(sql);
while (res.next())
{
TableItem it = new TableItem(table, SWT.NONE);
it.setText(0, "" + res.getString(1));
it.setText(1, "" + res.getString(2));
it.setText(2, "" + res.getString(3));
it.setText(3, "" + res.getString(4));
it.setText(4, "" + res.getString(5));
it.setText(5, "");
it.setText(6, "" + res.getString(6));
it.setText(7, "" + res.getString(7));
}
}
catch (Exception e)
{
MessageBox box = new MessageBox(new Shell());
box.setMessage("kann buchungen nicht abfragen: "
+ e.getMessage());
box.open();
}
}
My SQL statement returns the right data. Also, res.getString(*) contains
the right data (I have checked that with temporary data). Still, only
the first column will contain data - all other columns are blank.
There is no exception thrown.
Is it a bug?
By the way: I have just a small application so people can see the entire
code.
Hans
|
|
|
Re: Strange problem with SWT tables ... [message #450888 is a reply to message #450885] |
Sat, 19 February 2005 20:28 |
Brad Reynolds Messages: 309 Registered: July 2009 |
Senior Member |
|
|
I'm not an expert but with some quick code I whipped up it appears that
when adding TableItems before adding the TableColumns it displays this
behavior on windows. Move your fillBaseTable() call after the creation
of the TableColumns and see if it works.
Hans-Juergen Schoenig wrote:
> I have used SWT for a long time now.
> Today, we encountered a problem we have never seen before.
> We are using a simple SQL statement to build a table. The problem is
> that only the first column is actually filled with data.
> Does anybody know why? I am using Eclipse 3.0.0.
>
> Here is the code:
>
> Table table;
>
> table = new Table(shell, SWT.BORDER);
> table.setBounds(10, 15, 845, 370);
> table.setLinesVisible(true);
> table.setHeaderVisible(true);
> fillBaseTable();
>
> final TableColumn v_nr = new TableColumn(table, SWT.NONE);
> v_nr.setWidth(39);
> v_nr.setText("Nr.");
>
> final TableColumn v_datum = new TableColumn(table, SWT.NONE);
> v_datum.setWidth(91);
> v_datum.setText("Datum");
>
> final TableColumn v_beleg = new TableColumn(table, SWT.NONE);
> v_beleg.setWidth(77);
> v_beleg.setText("BelegNr");
>
> final TableColumn v_soll = new TableColumn(table, SWT.NONE);
> v_soll.setWidth(70);
> v_soll.setText("Soll");
>
> final TableColumn v_haben = new TableColumn(table, SWT.NONE);
> v_haben.setWidth(70);
> v_haben.setText("Haben");
>
> final TableColumn v_betrag = new TableColumn(table, SWT.NONE);
> v_betrag.setWidth(80);
> v_betrag.setText("Betrag");
>
> final TableColumn v_ust = new TableColumn(table, SWT.NONE);
> v_ust.setWidth(137);
> v_ust.setText("Ust.");
>
> final TableColumn v_text = new TableColumn(table, SWT.NONE);
> v_text.setWidth(100);
> v_text.setText("Text");
>
>
>
> public void fillBaseTable()
> {
> String sql = "SELECT id, tstamp::text, belegnt, sollbuch,
> habenbuch, betrag, beschreibung "
> + " FROM t_buchung "
> + " ORDER BY id, tstamp, sollbuch, habenbuch ";
> try
> {
> table.removeAll();
>
> Statement stmt = Config.conn.createStatement();
> ResultSet res = stmt.executeQuery(sql);
>
> while (res.next())
> {
> TableItem it = new TableItem(table, SWT.NONE);
> it.setText(0, "" + res.getString(1));
> it.setText(1, "" + res.getString(2));
> it.setText(2, "" + res.getString(3));
> it.setText(3, "" + res.getString(4));
> it.setText(4, "" + res.getString(5));
> it.setText(5, "");
> it.setText(6, "" + res.getString(6));
> it.setText(7, "" + res.getString(7));
> }
> }
> catch (Exception e)
> {
> MessageBox box = new MessageBox(new Shell());
> box.setMessage("kann buchungen nicht abfragen: "
> + e.getMessage());
> box.open();
> }
> }
>
> My SQL statement returns the right data. Also, res.getString(*) contains
> the right data (I have checked that with temporary data). Still, only
> the first column will contain data - all other columns are blank.
> There is no exception thrown.
>
> Is it a bug?
> By the way: I have just a small application so people can see the entire
> code.
>
> Hans
|
|
|
Re: Strange problem with SWT tables ... [message #451013 is a reply to message #450885] |
Mon, 21 February 2005 12:52 |
Veronika Irvine Messages: 1272 Registered: July 2009 |
Senior Member |
|
|
You need to create the TableColumn objects before calling fillBaseTable().
If you set text into a table item for a column that does not exist, it is
ignored.
"Hans-Juergen Schoenig" <hs@cybertec.at> wrote in message
news:421783D1.7060001@cybertec.at...
>I have used SWT for a long time now.
> Today, we encountered a problem we have never seen before.
> We are using a simple SQL statement to build a table. The problem is that
> only the first column is actually filled with data.
> Does anybody know why? I am using Eclipse 3.0.0.
>
> Here is the code:
>
> Table table;
>
> table = new Table(shell, SWT.BORDER);
> table.setBounds(10, 15, 845, 370);
> table.setLinesVisible(true);
> table.setHeaderVisible(true);
> fillBaseTable();
>
> final TableColumn v_nr = new TableColumn(table, SWT.NONE);
> v_nr.setWidth(39);
> v_nr.setText("Nr.");
>
> final TableColumn v_datum = new TableColumn(table, SWT.NONE);
> v_datum.setWidth(91);
> v_datum.setText("Datum");
>
> final TableColumn v_beleg = new TableColumn(table, SWT.NONE);
> v_beleg.setWidth(77);
> v_beleg.setText("BelegNr");
>
> final TableColumn v_soll = new TableColumn(table, SWT.NONE);
> v_soll.setWidth(70);
> v_soll.setText("Soll");
>
> final TableColumn v_haben = new TableColumn(table, SWT.NONE);
> v_haben.setWidth(70);
> v_haben.setText("Haben");
>
> final TableColumn v_betrag = new TableColumn(table, SWT.NONE);
> v_betrag.setWidth(80);
> v_betrag.setText("Betrag");
>
> final TableColumn v_ust = new TableColumn(table, SWT.NONE);
> v_ust.setWidth(137);
> v_ust.setText("Ust.");
>
> final TableColumn v_text = new TableColumn(table, SWT.NONE);
> v_text.setWidth(100);
> v_text.setText("Text");
>
>
>
> public void fillBaseTable()
> {
> String sql = "SELECT id, tstamp::text, belegnt, sollbuch,
> habenbuch, betrag, beschreibung "
> + " FROM t_buchung "
> + " ORDER BY id, tstamp, sollbuch, habenbuch ";
> try
> {
> table.removeAll();
>
> Statement stmt = Config.conn.createStatement();
> ResultSet res = stmt.executeQuery(sql);
>
> while (res.next())
> {
> TableItem it = new TableItem(table, SWT.NONE);
> it.setText(0, "" + res.getString(1));
> it.setText(1, "" + res.getString(2));
> it.setText(2, "" + res.getString(3));
> it.setText(3, "" + res.getString(4));
> it.setText(4, "" + res.getString(5));
> it.setText(5, "");
> it.setText(6, "" + res.getString(6));
> it.setText(7, "" + res.getString(7));
> }
> }
> catch (Exception e)
> {
> MessageBox box = new MessageBox(new Shell());
> box.setMessage("kann buchungen nicht abfragen: "
> + e.getMessage());
> box.open();
> }
> }
>
> My SQL statement returns the right data. Also, res.getString(*) contains
> the right data (I have checked that with temporary data). Still, only the
> first column will contain data - all other columns are blank.
> There is no exception thrown.
>
> Is it a bug?
> By the way: I have just a small application so people can see the entire
> code.
>
> Hans
|
|
|
Re: Strange problem with SWT tables ... [message #451024 is a reply to message #450888] |
Mon, 21 February 2005 17:08 |
Eclipse User |
|
|
|
Originally posted by: hs.cybertec.at
shame on me, shame on me ...
you are right.
i wonder why swt did not complain about that.
seems almost like a bug.
many thanks - after hours of searching it works now :).
many thanks and best regards,
hans
Brad Reynolds wrote:
> I'm not an expert but with some quick code I whipped up it appears that
> when adding TableItems before adding the TableColumns it displays this
> behavior on windows. Move your fillBaseTable() call after the creation
> of the TableColumns and see if it works.
>
> Hans-Juergen Schoenig wrote:
>
>> I have used SWT for a long time now.
>> Today, we encountered a problem we have never seen before.
>> We are using a simple SQL statement to build a table. The problem is
>> that only the first column is actually filled with data.
>> Does anybody know why? I am using Eclipse 3.0.0.
>>
>> Here is the code:
>>
>> Table table;
>>
>> table = new Table(shell, SWT.BORDER);
>> table.setBounds(10, 15, 845, 370);
>> table.setLinesVisible(true);
>> table.setHeaderVisible(true);
>> fillBaseTable();
>>
>> final TableColumn v_nr = new TableColumn(table, SWT.NONE);
>> v_nr.setWidth(39);
>> v_nr.setText("Nr.");
>>
>> final TableColumn v_datum = new TableColumn(table, SWT.NONE);
>> v_datum.setWidth(91);
>> v_datum.setText("Datum");
>>
>> final TableColumn v_beleg = new TableColumn(table, SWT.NONE);
>> v_beleg.setWidth(77);
>> v_beleg.setText("BelegNr");
>>
>> final TableColumn v_soll = new TableColumn(table, SWT.NONE);
>> v_soll.setWidth(70);
>> v_soll.setText("Soll");
>>
>> final TableColumn v_haben = new TableColumn(table, SWT.NONE);
>> v_haben.setWidth(70);
>> v_haben.setText("Haben");
>>
>> final TableColumn v_betrag = new TableColumn(table, SWT.NONE);
>> v_betrag.setWidth(80);
>> v_betrag.setText("Betrag");
>>
>> final TableColumn v_ust = new TableColumn(table, SWT.NONE);
>> v_ust.setWidth(137);
>> v_ust.setText("Ust.");
>>
>> final TableColumn v_text = new TableColumn(table, SWT.NONE);
>> v_text.setWidth(100);
>> v_text.setText("Text");
>>
>>
>>
>> public void fillBaseTable()
>> {
>> String sql = "SELECT id, tstamp::text, belegnt, sollbuch,
>> habenbuch, betrag, beschreibung "
>> + " FROM t_buchung "
>> + " ORDER BY id, tstamp, sollbuch, habenbuch ";
>> try
>> {
>> table.removeAll();
>> Statement stmt = Config.conn.createStatement();
>> ResultSet res = stmt.executeQuery(sql);
>> while (res.next())
>> {
>> TableItem it = new TableItem(table, SWT.NONE);
>> it.setText(0, "" + res.getString(1));
>> it.setText(1, "" + res.getString(2));
>> it.setText(2, "" + res.getString(3));
>> it.setText(3, "" + res.getString(4));
>> it.setText(4, "" + res.getString(5));
>> it.setText(5, "");
>> it.setText(6, "" + res.getString(6));
>> it.setText(7, "" + res.getString(7));
>> }
>> }
>> catch (Exception e)
>> {
>> MessageBox box = new MessageBox(new Shell());
>> box.setMessage("kann buchungen nicht abfragen: "
>> + e.getMessage());
>> box.open();
>> }
>> }
>>
>> My SQL statement returns the right data. Also, res.getString(*)
>> contains the right data (I have checked that with temporary data).
>> Still, only the first column will contain data - all other columns are
>> blank.
>> There is no exception thrown.
>>
>> Is it a bug?
>> By the way: I have just a small application so people can see the
>> entire code.
>>
>> Hans
|
|
|
Re: Strange problem with SWT tables ... [message #451062 is a reply to message #450888] |
Tue, 22 February 2005 13:38 |
Steve Northover Messages: 1636 Registered: July 2009 |
Senior Member |
|
|
If there really is a platform difference between Windows and where ever else
you are running, please enter a bug report.
"Brad Reynolds" <bradleyjames@gmail.com> wrote in message
news:cv87hr$4n8$1@www.eclipse.org...
> I'm not an expert but with some quick code I whipped up it appears that
> when adding TableItems before adding the TableColumns it displays this
> behavior on windows. Move your fillBaseTable() call after the creation
> of the TableColumns and see if it works.
>
> Hans-Juergen Schoenig wrote:
> > I have used SWT for a long time now.
> > Today, we encountered a problem we have never seen before.
> > We are using a simple SQL statement to build a table. The problem is
> > that only the first column is actually filled with data.
> > Does anybody know why? I am using Eclipse 3.0.0.
> >
> > Here is the code:
> >
> > Table table;
> >
> > table = new Table(shell, SWT.BORDER);
> > table.setBounds(10, 15, 845, 370);
> > table.setLinesVisible(true);
> > table.setHeaderVisible(true);
> > fillBaseTable();
> >
> > final TableColumn v_nr = new TableColumn(table, SWT.NONE);
> > v_nr.setWidth(39);
> > v_nr.setText("Nr.");
> >
> > final TableColumn v_datum = new TableColumn(table, SWT.NONE);
> > v_datum.setWidth(91);
> > v_datum.setText("Datum");
> >
> > final TableColumn v_beleg = new TableColumn(table, SWT.NONE);
> > v_beleg.setWidth(77);
> > v_beleg.setText("BelegNr");
> >
> > final TableColumn v_soll = new TableColumn(table, SWT.NONE);
> > v_soll.setWidth(70);
> > v_soll.setText("Soll");
> >
> > final TableColumn v_haben = new TableColumn(table, SWT.NONE);
> > v_haben.setWidth(70);
> > v_haben.setText("Haben");
> >
> > final TableColumn v_betrag = new TableColumn(table, SWT.NONE);
> > v_betrag.setWidth(80);
> > v_betrag.setText("Betrag");
> >
> > final TableColumn v_ust = new TableColumn(table, SWT.NONE);
> > v_ust.setWidth(137);
> > v_ust.setText("Ust.");
> >
> > final TableColumn v_text = new TableColumn(table, SWT.NONE);
> > v_text.setWidth(100);
> > v_text.setText("Text");
> >
> >
> >
> > public void fillBaseTable()
> > {
> > String sql = "SELECT id, tstamp::text, belegnt, sollbuch,
> > habenbuch, betrag, beschreibung "
> > + " FROM t_buchung "
> > + " ORDER BY id, tstamp, sollbuch, habenbuch ";
> > try
> > {
> > table.removeAll();
> >
> > Statement stmt = Config.conn.createStatement();
> > ResultSet res = stmt.executeQuery(sql);
> >
> > while (res.next())
> > {
> > TableItem it = new TableItem(table, SWT.NONE);
> > it.setText(0, "" + res.getString(1));
> > it.setText(1, "" + res.getString(2));
> > it.setText(2, "" + res.getString(3));
> > it.setText(3, "" + res.getString(4));
> > it.setText(4, "" + res.getString(5));
> > it.setText(5, "");
> > it.setText(6, "" + res.getString(6));
> > it.setText(7, "" + res.getString(7));
> > }
> > }
> > catch (Exception e)
> > {
> > MessageBox box = new MessageBox(new Shell());
> > box.setMessage("kann buchungen nicht abfragen: "
> > + e.getMessage());
> > box.open();
> > }
> > }
> >
> > My SQL statement returns the right data. Also, res.getString(*) contains
> > the right data (I have checked that with temporary data). Still, only
> > the first column will contain data - all other columns are blank.
> > There is no exception thrown.
> >
> > Is it a bug?
> > By the way: I have just a small application so people can see the entire
> > code.
> >
> > Hans
|
|
|
Goto Forum:
Current Time: Fri Apr 26 21:41:02 GMT 2024
Powered by FUDForum. Page generated in 0.03195 seconds
|