Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Scroll within a tableItem
Scroll within a tableItem [message #532566] Mon, 10 May 2010 13:15 Go to next message
nir dweck is currently offline nir dweckFriend
Messages: 17
Registered: April 2010
Junior Member
I have a tableItem which its control extends the size of the screen, but I can't get to add a scroll. I was able to add a scroll, but it didn't reach the the end of the tableItem. I wrote a short program which illustrates the problem (my code is much more complex and I use a lot of layers).
The example includes a tabFolder with a single tabItem. I added a grid layout with 5 labels. When I shrink the dialog, I can't see the right end of the strings.
here is the code:
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;

public class SimulateView {

	static public void main(){
		Shell m_shell;
		Display display = PlatformUI.getWorkbench().getDisplay();
		m_shell = new Shell(display, SWT.SHELL_TRIM /*| SWT.SCROLL_LINE/*| SWT.H_SCROLL | SWT.CLIP_CHILDREN | SWT.CLIP_SIBLINGS*/ /*| SWT.SCROLL_PAGE*/);
		m_shell.setText("Simulation");
		FillLayout flayout = new FillLayout(SWT.FILL);
		flayout.marginHeight = 0;
		flayout.marginWidth = 5;
		m_shell.setLayout(flayout);
		//create the tab folder
		CTabFolder tab = new CTabFolder(m_shell, SWT.TOP );
		//create the tab item
		CTabItem item = new CTabItem(tab, SWT.RESIZE | SWT.H_SCROLL);
		item.setText("tab Item");
		//create the top 3 labels
		Composite topcomposite = new Composite(tab, SWT.RESIZE | SWT.SCROLL_PAGE);
		topcomposite.setLayout(new GridLayout(5, true));

		new Label(topcomposite, SWT.NONE).setText("first Lable ");
		new Label(topcomposite, SWT.NONE).setText("            ");
		new Label(topcomposite, SWT.NONE).setText("second Lable");
		new Label(topcomposite, SWT.NONE).setText("            ");
		new Label(topcomposite, SWT.NONE).setText("third Lable ");
		item.setControl(topcomposite);
		m_shell.open();
	}
}

I couldn't figure out how to add a PNG of my dialog.
Thanks,
Nir
Re: Scroll within a tableItem [message #532567 is a reply to message #532566] Mon, 10 May 2010 13:19 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6499
Registered: July 2009
Senior Member
You need to use a ScrolledComposite inside the TabItem.

Tom

Am 10.05.10 15:15, schrieb nir dweck:
> I have a tableItem which its control extends the size of the screen, but
> I can't get to add a scroll. I was able to add a scroll, but it didn't
> reach the the end of the tableItem. I wrote a short program which
> illustrates the problem (my code is much more complex and I use a lot of
> layers). The example includes a tabFolder with a single tabItem. I added
> a grid layout with 5 labels. When I shrink the dialog, I can't see the
> right end of the strings.
> here is the code:
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.custom.CTabFolder;
> import org.eclipse.swt.custom.CTabItem;
> import org.eclipse.swt.layout.FillLayout;
> import org.eclipse.swt.layout.GridLayout;
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Label;
> import org.eclipse.swt.widgets.Shell;
> import org.eclipse.ui.PlatformUI;
>
> public class SimulateView {
>
> static public void main(){
> Shell m_shell;
> Display display = PlatformUI.getWorkbench().getDisplay();
> m_shell = new Shell(display, SWT.SHELL_TRIM /*|
> SWT.SCROLL_LINE/*| SWT.H_SCROLL | SWT.CLIP_CHILDREN |
> SWT.CLIP_SIBLINGS*/ /*| SWT.SCROLL_PAGE*/);
> m_shell.setText("Simulation");
> FillLayout flayout = new FillLayout(SWT.FILL);
> flayout.marginHeight = 0;
> flayout.marginWidth = 5;
> m_shell.setLayout(flayout);
> //create the tab folder
> CTabFolder tab = new CTabFolder(m_shell, SWT.TOP );
> //create the tab item
> CTabItem item = new CTabItem(tab, SWT.RESIZE | SWT.H_SCROLL);
> item.setText("tab Item");
> //create the top 3 labels
> Composite topcomposite = new Composite(tab, SWT.RESIZE |
> SWT.SCROLL_PAGE);
> topcomposite.setLayout(new GridLayout(5, true));
>
> new Label(topcomposite, SWT.NONE).setText("first Lable ");
> new Label(topcomposite, SWT.NONE).setText(" ");
> new Label(topcomposite, SWT.NONE).setText("second Lable");
> new Label(topcomposite, SWT.NONE).setText(" ");
> new Label(topcomposite, SWT.NONE).setText("third Lable ");
> item.setControl(topcomposite);
> m_shell.open();
> }
> }
>
> I couldn't figure out how to add a PNG of my dialog.
> Thanks,
> Nir
>
Re: Scroll within a tableItem [message #532666 is a reply to message #532567] Mon, 10 May 2010 18:13 Go to previous message
nir dweck is currently offline nir dweckFriend
Messages: 17
Registered: April 2010
Junior Member
Thanks,
I new it was something simple I am missing. now it works great.
Thanks,
Nir
Previous Topic:Running Long UIJobs with progress(is this the solution?)
Next Topic:StyledCellLabelProvider ignores fontStyle
Goto Forum:
  


Current Time: Tue Aug 20 05:32:24 GMT 2019

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

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

Back to the top