Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Scrolled Composite Bars
Scrolled Composite Bars [message #916656] Wed, 19 September 2012 09:30 Go to next message
Nico Smeenk is currently offline Nico SmeenkFriend
Messages: 1
Registered: September 2012
Junior Member
Hi,

i've an big problem with the ScrolledComposite from SWT. For a game i created an SC to scroll over a map. You can do this with your mouse. My problem: I don't want to have the bars, but i need SWT.H_SCROL and SWT.V_SCROLL to use setOrigin on myselve.

.getHorizontalBar().setVisible(false);
and
.getVerticalBar().setVisible(false);


dont work. I hope you can help me!
thx
Re: Scrolled Composite Bars [message #930678 is a reply to message #916656] Tue, 02 October 2012 14:31 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
It sounds like ScrolledComposite is not what you need then. You can
replicate the functionality of setOrigin() in a normal Composite by just
changing the location of its child (negative values are fine). This is
demonstrated in the following snippet:

public class ModifiedSnippet172 {
public static void main (String [] args) {
final Display display = new Display ();
final Shell shell = new Shell (display);
final Composite composite = new Composite(shell, SWT.NONE);
GridLayout layout = new GridLayout(4, false);
composite.setLayout(layout);
Button b = new Button(composite, SWT.PUSH);
b.setText("LEFT, TOP");
b.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1));
b = new Button(composite, SWT.PUSH);
b.setText("LEFT, CENTER");
b.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true, 1, 1));
b = new Button(composite, SWT.PUSH);
b.setText("LEFT, BOTTOM");
b.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true, 1, 1));
b = new Button(composite, SWT.PUSH);
b.setText("LEFT, FILL");
b.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, true, 1, 1));
b = new Button(composite, SWT.PUSH);
b.setText("CENTER, TOP");
b.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, true, 1, 1));
b = new Button(composite, SWT.PUSH);
b.setText("CENTER, CENTER");
b.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true, 1,
1));
b = new Button(composite, SWT.PUSH);
b.setText("CENTER, BOTTOM");
b.setLayoutData(new GridData(SWT.CENTER, SWT.BOTTOM, true, true, 1,
1));
b = new Button(composite, SWT.PUSH);
b.setText("CENTER, FILL");
b.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true, true, 1, 1));
b = new Button(composite, SWT.PUSH);
b.setText("RIGHT, TOP");
b.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, true, true, 1, 1));
b = new Button(composite, SWT.PUSH);
b.setText("RIGHT, CENTER");
b.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, true, 1, 1));
b = new Button(composite, SWT.PUSH);
b.setText("RIGHT, BOTTOM");
b.setLayoutData(new GridData(SWT.RIGHT, SWT.BOTTOM, true, true, 1, 1));
b = new Button(composite, SWT.PUSH);
b.setText("RIGHT, FILL");
b.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, true, 1, 1));
b = new Button(composite, SWT.PUSH);
b.setText("FILL, TOP");
b.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 1, 1));
b = new Button(composite, SWT.PUSH);
b.setText("FILL, CENTER");
b.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1));
b = new Button(composite, SWT.PUSH);
b.setText("FILL, BOTTOM");
b.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, true, 1, 1));
b = new Button(composite, SWT.PUSH);
b.setText("FILL, FILL");
b.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
composite.setBounds(0,0,size.x, size.y);
shell.pack();
Runnable runnable = new Runnable() {
public void run() {
if (shell.isDisposed()) return;
Point location = composite.getLocation();
location.x -= 10;
location.y -= 10;
composite.setLocation(location);
display.timerExec(1111, this);
}
};
display.timerExec(1111, runnable);
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}

Grant


On 9/19/2012 5:30 AM, Nico Smeenk wrote:
> Hi,
>
> i've an big problem with the ScrolledComposite from SWT. For a game i
> created an SC to scroll over a map. You can do this with your mouse. My
> problem: I don't want to have the bars, but i need SWT.H_SCROL and
> SWT.V_SCROLL to use setOrigin on myselve.
> getHorizontalBar().setVisible(false); and
> .getVerticalBar().setVisible(false);
>
> dont work. I hope you can help me! thx
Previous Topic:How to specify a relative path to a XULRunner?
Next Topic:How to configure browser prefs for XULRunner 10.x?
Goto Forum:
  


Current Time: Fri Mar 29 08:46:20 GMT 2024

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

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

Back to the top