|
Re: Is there a way to always show the scrollbar for a List? [message #537334 is a reply to message #537264] |
Wed, 02 June 2010 05:30 |
Vijay Raj Messages: 608 Registered: July 2009 |
Senior Member |
|
|
package org.eclipse.swt.snippets;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.swt.widgets.Shell;
public class Snippet
{
static Display display;
static Shell shell;
public static void main(String[] args)
{
display = new Display();
shell = new Shell(display);
shell.setSize(300, 300);
shell.open();
shell.setLayout(new GridLayout(5, true));
List list = new List(shell, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
GridData layoutData = new GridData(GridData.FILL_BOTH);
list.setLayoutData(layoutData);
list.setItems(new String[] { "1", "2", "3" });
list.addSelectionListener(new SelectionListener()
{
@Override
public void widgetSelected(SelectionEvent e)
{
// TODO Auto-generated method stub
}
@Override
public void widgetDefaultSelected(SelectionEvent e)
{
System.out.println();
}
});
shell.layout();
ScrollBar hBar = list.getHorizontalBar();
if (hBar != null) hBar.setVisible(true);
ScrollBar vBar = list.getVerticalBar();
if (vBar != null) vBar.setVisible(true);
while (!shell.isDisposed())
{
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
}
pls modify the code further to sute your needs...
---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
[Updated on: Wed, 02 June 2010 05:33] Report message to a moderator
|
|
|
|
Re: Is there a way to always show the scrollbar for a List? [message #537885 is a reply to message #537881] |
Fri, 04 June 2010 04:55 |
Vijay Raj Messages: 608 Registered: July 2009 |
Senior Member |
|
|
Notice that the layout is done defore and setting visible is done after...
shell.layout();
ScrollBar hBar = list.getHorizontalBar();
if (hBar != null) hBar.setVisible(true);
ScrollBar vBar = list.getVerticalBar();
if (vBar != null) vBar.setVisible(true);
if u do it the other way the same thing will happen which is happening to u...
---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
|
|
|
|
Powered by
FUDForum. Page generated in 0.02173 seconds