Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Tablecolumn + icon and TableItem Alignment problems
| Tablecolumn + icon and TableItem Alignment problems [message #385544] |
Wed, 12 November 2003 20:09  |
Eclipse User |
|
|
|
First, apologies for the long snippet.
I am having problem with understanding the behaviour of the setAlignment
method on the TableColumn. I can align text in the whole column of a table
quite nicely but am running into problems with I have an image on the
TableColumn as well. Basically it looks as though you can have one or the
other.
I have an example which by default sets the table alightment to SWT.RIGHT
for each column, and also has an image on the tableColumn (appears when you
click on the TableColumn) you will see depending on the order in which
setAlignment and setImage are called, you EITHER get an Image OR correctly
aligned text.
Is this a bug?
Thanks
public class Main {
static public TableListener listener = new TableListener();
static public Image image = null;
static public Image image2 = null;
static public class TableListener implements SelectionListener
{
public void widgetDefaultSelected(SelectionEvent arg0) {
// TODO Auto-generated method stub
}
public void widgetSelected(SelectionEvent arg0)
{
if(arg0.getSource() instanceof TableColumn)
{
TableColumn column = (TableColumn)arg0.getSource();
if(column.getImage() == image)
{
// you can see an image this time
// but text is incorrectly aligned
column.setImage(image2);
}
else
{
// text is correctly aligned
// but you cannot see the image!
column.setImage(image);
column.setAlignment(SWT.RIGHT);
}
}
}
}
public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
image = new Image (display, 20, 20);
Color color = display.getSystemColor (SWT.COLOR_BLUE);
GC gc = new GC (image);
gc.setBackground (color);
gc.fillRectangle (image.getBounds ());
gc.dispose ();
image2 = new Image (display, 20, 20);
Color color2 = display.getSystemColor (SWT.COLOR_RED);
GC gc2 = new GC (image2);
gc2.setBackground (color2);
gc2.fillRectangle (image.getBounds ());
gc2.dispose ();
Table table = new Table (shell, SWT.MULTI | SWT.BORDER |
SWT.FULL_SELECTION);
table.setLinesVisible (true);
table.setHeaderVisible (true);
String[] titles = {" ", "C", "!", "Description", "Resource", "In Folder",
"Location"};
for (int i=0; i<titles.length; i++) {
TableColumn column = new TableColumn (table, SWT.NULL);
column.addSelectionListener(listener);
column.setText (titles [i]);
column.setImage(image);
column.setAlignment(SWT.RIGHT);
}
int count = 128;
for (int i=0; i<count; i++) {
TableItem item = new TableItem (table, SWT.NULL);
item.setText (0, i+"");
item.setText (1, "y");
item.setText (2, "!");
item.setText (3, "this stuff behaves the way I expect");
item.setText (4, "almost everywhere");
item.setText (5, "some.folder");
item.setText (6, "line " + i + " in nowhere");
}
for (int i=0; i<titles.length; i++) {
table.getColumn (i).pack ();
}
table.setSize (table.computeSize (SWT.DEFAULT, 200));
shell.pack ();
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
|
|
|
| Re: Tablecolumn + icon and TableItem Alignment problems [message #385546 is a reply to message #385544] |
Wed, 12 November 2003 20:11   |
Eclipse User |
|
|
|
P.S. This is under windows XP with Eclipse 3.0 Build id: 200307181617
"Vadalus" <vadalus@pobox.com> wrote in message
news:boulgh$nn8$1@eclipse.org...
> First, apologies for the long snippet.
>
> I am having problem with understanding the behaviour of the setAlignment
> method on the TableColumn. I can align text in the whole column of a table
> quite nicely but am running into problems with I have an image on the
> TableColumn as well. Basically it looks as though you can have one or the
> other.
>
> I have an example which by default sets the table alightment to SWT.RIGHT
> for each column, and also has an image on the tableColumn (appears when
you
> click on the TableColumn) you will see depending on the order in which
> setAlignment and setImage are called, you EITHER get an Image OR correctly
> aligned text.
>
> Is this a bug?
>
> Thanks
>
>
> public class Main {
> static public TableListener listener = new TableListener();
> static public Image image = null;
> static public Image image2 = null;
>
> static public class TableListener implements SelectionListener
> {
> public void widgetDefaultSelected(SelectionEvent arg0) {
> // TODO Auto-generated method stub
>
> }
> public void widgetSelected(SelectionEvent arg0)
> {
> if(arg0.getSource() instanceof TableColumn)
> {
> TableColumn column = (TableColumn)arg0.getSource();
>
> if(column.getImage() == image)
> {
> // you can see an image this time
> // but text is incorrectly aligned
> column.setImage(image2);
> }
> else
> {
> // text is correctly aligned
> // but you cannot see the image!
> column.setImage(image);
> column.setAlignment(SWT.RIGHT);
> }
> }
>
> }
> }
> public static void main (String [] args) {
> Display display = new Display ();
> Shell shell = new Shell (display);
>
> image = new Image (display, 20, 20);
> Color color = display.getSystemColor (SWT.COLOR_BLUE);
> GC gc = new GC (image);
> gc.setBackground (color);
> gc.fillRectangle (image.getBounds ());
> gc.dispose ();
>
> image2 = new Image (display, 20, 20);
> Color color2 = display.getSystemColor (SWT.COLOR_RED);
> GC gc2 = new GC (image2);
> gc2.setBackground (color2);
> gc2.fillRectangle (image.getBounds ());
> gc2.dispose ();
>
>
> Table table = new Table (shell, SWT.MULTI | SWT.BORDER |
> SWT.FULL_SELECTION);
> table.setLinesVisible (true);
> table.setHeaderVisible (true);
> String[] titles = {" ", "C", "!", "Description", "Resource", "In Folder",
> "Location"};
> for (int i=0; i<titles.length; i++) {
> TableColumn column = new TableColumn (table, SWT.NULL);
> column.addSelectionListener(listener);
> column.setText (titles [i]);
> column.setImage(image);
> column.setAlignment(SWT.RIGHT);
> }
> int count = 128;
> for (int i=0; i<count; i++) {
> TableItem item = new TableItem (table, SWT.NULL);
> item.setText (0, i+"");
> item.setText (1, "y");
> item.setText (2, "!");
> item.setText (3, "this stuff behaves the way I expect");
> item.setText (4, "almost everywhere");
> item.setText (5, "some.folder");
> item.setText (6, "line " + i + " in nowhere");
> }
> for (int i=0; i<titles.length; i++) {
> table.getColumn (i).pack ();
> }
> table.setSize (table.computeSize (SWT.DEFAULT, 200));
> shell.pack ();
> shell.open ();
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
>
>
|
|
|
| Re: Tablecolumn + icon and TableItem Alignment problems [message #386040 is a reply to message #385544] |
Thu, 13 November 2003 08:32   |
Eclipse User |
|
|
|
Tried your example and it seems like a bug. Can you please enter a bug
report against Platform SWT for this? Thank you.
"Vadalus" <vadalus@pobox.com> wrote in message
news:boulgh$nn8$1@eclipse.org...
> First, apologies for the long snippet.
>
> I am having problem with understanding the behaviour of the setAlignment
> method on the TableColumn. I can align text in the whole column of a table
> quite nicely but am running into problems with I have an image on the
> TableColumn as well. Basically it looks as though you can have one or the
> other.
>
> I have an example which by default sets the table alightment to SWT.RIGHT
> for each column, and also has an image on the tableColumn (appears when
you
> click on the TableColumn) you will see depending on the order in which
> setAlignment and setImage are called, you EITHER get an Image OR correctly
> aligned text.
>
> Is this a bug?
>
> Thanks
>
>
> public class Main {
> static public TableListener listener = new TableListener();
> static public Image image = null;
> static public Image image2 = null;
>
> static public class TableListener implements SelectionListener
> {
> public void widgetDefaultSelected(SelectionEvent arg0) {
> // TODO Auto-generated method stub
>
> }
> public void widgetSelected(SelectionEvent arg0)
> {
> if(arg0.getSource() instanceof TableColumn)
> {
> TableColumn column = (TableColumn)arg0.getSource();
>
> if(column.getImage() == image)
> {
> // you can see an image this time
> // but text is incorrectly aligned
> column.setImage(image2);
> }
> else
> {
> // text is correctly aligned
> // but you cannot see the image!
> column.setImage(image);
> column.setAlignment(SWT.RIGHT);
> }
> }
>
> }
> }
> public static void main (String [] args) {
> Display display = new Display ();
> Shell shell = new Shell (display);
>
> image = new Image (display, 20, 20);
> Color color = display.getSystemColor (SWT.COLOR_BLUE);
> GC gc = new GC (image);
> gc.setBackground (color);
> gc.fillRectangle (image.getBounds ());
> gc.dispose ();
>
> image2 = new Image (display, 20, 20);
> Color color2 = display.getSystemColor (SWT.COLOR_RED);
> GC gc2 = new GC (image2);
> gc2.setBackground (color2);
> gc2.fillRectangle (image.getBounds ());
> gc2.dispose ();
>
>
> Table table = new Table (shell, SWT.MULTI | SWT.BORDER |
> SWT.FULL_SELECTION);
> table.setLinesVisible (true);
> table.setHeaderVisible (true);
> String[] titles = {" ", "C", "!", "Description", "Resource", "In Folder",
> "Location"};
> for (int i=0; i<titles.length; i++) {
> TableColumn column = new TableColumn (table, SWT.NULL);
> column.addSelectionListener(listener);
> column.setText (titles [i]);
> column.setImage(image);
> column.setAlignment(SWT.RIGHT);
> }
> int count = 128;
> for (int i=0; i<count; i++) {
> TableItem item = new TableItem (table, SWT.NULL);
> item.setText (0, i+"");
> item.setText (1, "y");
> item.setText (2, "!");
> item.setText (3, "this stuff behaves the way I expect");
> item.setText (4, "almost everywhere");
> item.setText (5, "some.folder");
> item.setText (6, "line " + i + " in nowhere");
> }
> for (int i=0; i<titles.length; i++) {
> table.getColumn (i).pack ();
> }
> table.setSize (table.computeSize (SWT.DEFAULT, 200));
> shell.pack ();
> shell.open ();
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
>
>
|
|
|
| Re: Tablecolumn + icon and TableItem Alignment problems [message #386121 is a reply to message #385544] |
Thu, 13 November 2003 12:05   |
Eclipse User |
|
|
|
Fixed > 20031113
"Vadalus" <vadalus@pobox.com> wrote in message
news:boulgh$nn8$1@eclipse.org...
> First, apologies for the long snippet.
>
> I am having problem with understanding the behaviour of the setAlignment
> method on the TableColumn. I can align text in the whole column of a table
> quite nicely but am running into problems with I have an image on the
> TableColumn as well. Basically it looks as though you can have one or the
> other.
>
> I have an example which by default sets the table alightment to SWT.RIGHT
> for each column, and also has an image on the tableColumn (appears when
you
> click on the TableColumn) you will see depending on the order in which
> setAlignment and setImage are called, you EITHER get an Image OR correctly
> aligned text.
>
> Is this a bug?
>
> Thanks
>
>
> public class Main {
> static public TableListener listener = new TableListener();
> static public Image image = null;
> static public Image image2 = null;
>
> static public class TableListener implements SelectionListener
> {
> public void widgetDefaultSelected(SelectionEvent arg0) {
> // TODO Auto-generated method stub
>
> }
> public void widgetSelected(SelectionEvent arg0)
> {
> if(arg0.getSource() instanceof TableColumn)
> {
> TableColumn column = (TableColumn)arg0.getSource();
>
> if(column.getImage() == image)
> {
> // you can see an image this time
> // but text is incorrectly aligned
> column.setImage(image2);
> }
> else
> {
> // text is correctly aligned
> // but you cannot see the image!
> column.setImage(image);
> column.setAlignment(SWT.RIGHT);
> }
> }
>
> }
> }
> public static void main (String [] args) {
> Display display = new Display ();
> Shell shell = new Shell (display);
>
> image = new Image (display, 20, 20);
> Color color = display.getSystemColor (SWT.COLOR_BLUE);
> GC gc = new GC (image);
> gc.setBackground (color);
> gc.fillRectangle (image.getBounds ());
> gc.dispose ();
>
> image2 = new Image (display, 20, 20);
> Color color2 = display.getSystemColor (SWT.COLOR_RED);
> GC gc2 = new GC (image2);
> gc2.setBackground (color2);
> gc2.fillRectangle (image.getBounds ());
> gc2.dispose ();
>
>
> Table table = new Table (shell, SWT.MULTI | SWT.BORDER |
> SWT.FULL_SELECTION);
> table.setLinesVisible (true);
> table.setHeaderVisible (true);
> String[] titles = {" ", "C", "!", "Description", "Resource", "In Folder",
> "Location"};
> for (int i=0; i<titles.length; i++) {
> TableColumn column = new TableColumn (table, SWT.NULL);
> column.addSelectionListener(listener);
> column.setText (titles [i]);
> column.setImage(image);
> column.setAlignment(SWT.RIGHT);
> }
> int count = 128;
> for (int i=0; i<count; i++) {
> TableItem item = new TableItem (table, SWT.NULL);
> item.setText (0, i+"");
> item.setText (1, "y");
> item.setText (2, "!");
> item.setText (3, "this stuff behaves the way I expect");
> item.setText (4, "almost everywhere");
> item.setText (5, "some.folder");
> item.setText (6, "line " + i + " in nowhere");
> }
> for (int i=0; i<titles.length; i++) {
> table.getColumn (i).pack ();
> }
> table.setSize (table.computeSize (SWT.DEFAULT, 200));
> shell.pack ();
> shell.open ();
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
>
>
|
|
|
| Re: Tablecolumn + icon and TableItem Alignment problems [message #386135 is a reply to message #386121] |
Thu, 13 November 2003 16:50  |
Eclipse User |
|
|
|
great. thanks.
Liam
"Steve Northover" <steve_northover@ca.ibm.com> wrote in message
news:bp0dhd$h8v$1@eclipse.org...
> Fixed > 20031113
>
> "Vadalus" <vadalus@pobox.com> wrote in message
> news:boulgh$nn8$1@eclipse.org...
> > First, apologies for the long snippet.
> >
> > I am having problem with understanding the behaviour of the setAlignment
> > method on the TableColumn. I can align text in the whole column of a
table
> > quite nicely but am running into problems with I have an image on the
> > TableColumn as well. Basically it looks as though you can have one or
the
> > other.
> >
> > I have an example which by default sets the table alightment to
SWT.RIGHT
> > for each column, and also has an image on the tableColumn (appears when
> you
> > click on the TableColumn) you will see depending on the order in which
> > setAlignment and setImage are called, you EITHER get an Image OR
correctly
> > aligned text.
> >
> > Is this a bug?
> >
> > Thanks
> >
> >
> > public class Main {
> > static public TableListener listener = new TableListener();
> > static public Image image = null;
> > static public Image image2 = null;
> >
> > static public class TableListener implements SelectionListener
> > {
> > public void widgetDefaultSelected(SelectionEvent arg0) {
> > // TODO Auto-generated method stub
> >
> > }
> > public void widgetSelected(SelectionEvent arg0)
> > {
> > if(arg0.getSource() instanceof TableColumn)
> > {
> > TableColumn column = (TableColumn)arg0.getSource();
> >
> > if(column.getImage() == image)
> > {
> > // you can see an image this time
> > // but text is incorrectly aligned
> > column.setImage(image2);
> > }
> > else
> > {
> > // text is correctly aligned
> > // but you cannot see the image!
> > column.setImage(image);
> > column.setAlignment(SWT.RIGHT);
> > }
> > }
> >
> > }
> > }
> > public static void main (String [] args) {
> > Display display = new Display ();
> > Shell shell = new Shell (display);
> >
> > image = new Image (display, 20, 20);
> > Color color = display.getSystemColor (SWT.COLOR_BLUE);
> > GC gc = new GC (image);
> > gc.setBackground (color);
> > gc.fillRectangle (image.getBounds ());
> > gc.dispose ();
> >
> > image2 = new Image (display, 20, 20);
> > Color color2 = display.getSystemColor (SWT.COLOR_RED);
> > GC gc2 = new GC (image2);
> > gc2.setBackground (color2);
> > gc2.fillRectangle (image.getBounds ());
> > gc2.dispose ();
> >
> >
> > Table table = new Table (shell, SWT.MULTI | SWT.BORDER |
> > SWT.FULL_SELECTION);
> > table.setLinesVisible (true);
> > table.setHeaderVisible (true);
> > String[] titles = {" ", "C", "!", "Description", "Resource", "In
Folder",
> > "Location"};
> > for (int i=0; i<titles.length; i++) {
> > TableColumn column = new TableColumn (table, SWT.NULL);
> > column.addSelectionListener(listener);
> > column.setText (titles [i]);
> > column.setImage(image);
> > column.setAlignment(SWT.RIGHT);
> > }
> > int count = 128;
> > for (int i=0; i<count; i++) {
> > TableItem item = new TableItem (table, SWT.NULL);
> > item.setText (0, i+"");
> > item.setText (1, "y");
> > item.setText (2, "!");
> > item.setText (3, "this stuff behaves the way I expect");
> > item.setText (4, "almost everywhere");
> > item.setText (5, "some.folder");
> > item.setText (6, "line " + i + " in nowhere");
> > }
> > for (int i=0; i<titles.length; i++) {
> > table.getColumn (i).pack ();
> > }
> > table.setSize (table.computeSize (SWT.DEFAULT, 200));
> > shell.pack ();
> > shell.open ();
> > while (!shell.isDisposed ()) {
> > if (!display.readAndDispatch ()) display.sleep ();
> > }
> > display.dispose ();
> > }
> >
> >
>
>
|
|
|
Goto Forum:
Current Time: Tue Oct 28 16:28:47 EDT 2025
Powered by FUDForum. Page generated in 0.06944 seconds
|