Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Noob Table with ScrollBar question
Noob Table with ScrollBar question [message #456367] Wed, 01 June 2005 14:20
Marc Schaubach is currently offline Marc SchaubachFriend
Messages: 5
Registered: July 2009
Junior Member
Hello fellow SWT addicts :)

I need to code (in pure SWT) code that will keep a table scrolled to the
bottom ONLY if the user has the scroll bar at the bottom.

My code for adding a TableItem is below this post.

The problem with this code is that the first System.out.println will
give a result (say 27:72:45) which is correct.. then with this I can
tell if the scrollbar is at the bottom (which works, scroll_seek in the
code will be true). But the real issue comes at the bottom of the code
AFTER I have added the table item. I re-call the System.out.println and
even though there has been an item added, the results are the same..
27:72:45 -- it seems the table takes time to register the change. If I
put a breakpoint there, the TableItem has been added and the table size
has visually increase and the scroll bar is no longer at the bottom..
just the call to the scroll bar does not seem to have caught up. On
next call the first one now will read 27:90:45.. so my code fails to
correctly move the scrollbar. How can I resolve this.. is there some
listener I can add to the table to wait for the item to get added and
then alert on change?

Sorry for such a noob question.

Thanks for any help
Marc


public void addElement(final String to_add, final String color){
if(display != null && !display.isDisposed())
{
display.asyncExec( new Runnable() {
public void run() {
if(table1 != null && !table1.isDisposed())
{
boolean scroll_seek = false;

System.out.println(table1.getVerticalBar().getSelection() + " : " +
table1.getVerticalBar().getMaximum() + " : " +
table1.getVerticalBar().getThumb());
if((table1.getVerticalBar().getSelection()+
table1.getVerticalBar().getThumb()) ==
table1.getVerticalBar().getMaximum()){
scroll_seek = true;
}

TableItem item = new TableItem(table1,SWT.NULL);
item.setText("[" + getCurrentTime() + "] " + to_add);
if(color.equalsIgnoreCase("red"))

item.setForeground(display.getSystemColor(SWT.COLOR_DARK_RED ));
else if(color.equalsIgnoreCase("blue"))

item.setForeground(display.getSystemColor(SWT.COLOR_DARK_BLU E));
else if(color.equalsIgnoreCase("green"))

item.setForeground(display.getSystemColor(SWT.COLOR_DARK_GRE EN));

if(scroll_seek){

System.out.println(" New: " +
table1.getVerticalBar().getSelection() + " : " +
table1.getVerticalBar().getMaximum() + " : " +
table1.getVerticalBar().getThumb());


table1.getVerticalBar().setSelection(table1.getVerticalBar() .getMaximum()
- table1.getVerticalBar().getThumb());
}
}
}
});
}


}
Previous Topic:Halting a dispose
Next Topic:Intercept / Abort SWT.Close
Goto Forum:
  


Current Time: Thu Apr 25 19:28:30 GMT 2024

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

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

Back to the top