Home » Eclipse Projects » Eclipse Platform » Composite's Scrollbar issue
| |
Re: Composite's Scrollbar issue [message #538240 is a reply to message #538008] |
Mon, 07 June 2010 04:40 |
Jack Clouseau Messages: 22 Registered: June 2010 |
Junior Member |
|
|
Grant,
Thanks for the reply...i did even tried with ScrolledComposite before posting here...even that too didn''t work as expected.
Am pasting a sample code which you can run for yourself and check that the scrollbars eventhough it's visible and selectable still it doesn't do it's intended functionality.
This code is similar to the UI code of our project...please run this sample code and let me know..whether the scollbars are functioning in your system....if so, then please suggest me where i could be wrong...
If it;s not functional even in your system...please let me know how to make it work...
As far as i know, the code looks fine, but i gues i have missed out something and may be that is creating the problem....
here is the sample code:
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
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.swt.widgets.Text;
/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class ScrolledCompTest extends org.eclipse.swt.widgets.Composite {
/**
* Auto-generated main method to display this
* org.eclipse.swt.widgets.Composite inside a new Shell.
*/
public static void main(String[] args) {
showGUI();
}
/**
* Overriding checkSubclass allows this class to extend org.eclipse.swt.widgets.Composite
*/
protected void checkSubclass() {
}
/**
* Auto-generated method to display this
* org.eclipse.swt.widgets.Composite inside a new Shell.
*/
public static void showGUI() {
Display display = Display.getDefault();
Shell shell = new Shell(display);
ScrolledCompTest inst = new ScrolledCompTest(shell, SWT.NULL);
Point size = inst.getSize();
shell.setLayout(new FillLayout());
shell.layout();
if(size.x == 0 && size.y == 0) {
inst.pack();
shell.pack();
} else {
Rectangle shellBounds = shell.computeTrim(0, 0, size.x, size.y);
shell.setSize(shellBounds.width, shellBounds.height);
}
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
public ScrolledCompTest(org.eclipse.swt.widgets.Composite parent, int style) {
super(parent, style);
initGUI();
}
private void initGUI() {
try {
GridLayout thisLayout = new GridLayout();
this.setLayout(thisLayout);
this.layout();
final ScrolledComposite scrollComposite = new ScrolledComposite(this, SWT.V_SCROLL | SWT.BORDER);
GridLayout scrolCompLyt = new GridLayout(1, false);
GridData scrolCompLytData = new GridData();
scrolCompLytData.widthHint = 230;
scrolCompLytData.heightHint = 200;
scrollComposite.setLayout(scrolCompLyt);
scrollComposite.setLayoutData(scrolCompLytData);
final Composite comp = new Composite(scrollComposite, SWT.H_SCROLL | SWT.V_SCROLL);
GridLayout compLyt = new GridLayout(2, false);
GridData compLytData = new GridData();
compLytData.widthHint = 300;
compLytData.heightHint = 200;
comp.setLayout(compLyt);
comp.setLayoutData(compLytData);
Label l = new Label(comp, SWT.BORDER);;
l.setText("this is sample lable");
GridData ldata = new GridData();
ldata.widthHint = 200;
l.setLayoutData(ldata);
Text t = new Text(comp, SWT.BORDER);
t.setText("hello");
GridData tdata = new GridData();
tdata.widthHint = 100;
t.setLayoutData(ldata);
scrollComposite.setContent(comp);
scrollComposite.setExpandVertical(true);
scrollComposite.setExpandHorizontal(true);
//pack();
} catch (Exception e) {
e.printStackTrace();
}
}
}
when you run this sample code...by default scroll bars are visible...since the TextField which has text "Hello" is not completely visible.....now when i try to move the scrollbar horizontally to view the hidden text, it doesn;t work...please let me know if you too have this issue....please revert back as soon as possible.....
NOTE::: Anybody can run this code and let me know if the scrollbars are functional...and if possible please tell me where am i going wrong!!!!!
Any suggestions at the earliest will be very grateful...
Thanks...
|
|
|
Re: Composite's Scrollbar issue [message #538251 is a reply to message #538240] |
Mon, 07 June 2010 06:29 |
Jack Clouseau Messages: 22 Registered: June 2010 |
Junior Member |
|
|
AllRight...
Guys i found out the problem where i was doing wrong...it was the layout issue. For the control on which we are going to draw the ScrolledComposite should have a "FillLayout"..this way it works...
You guys can check the modified below code which works exactly as expected...
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
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.swt.widgets.Text;
/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class ScrolledCompTest extends org.eclipse.swt.widgets.Composite {
/**
* Auto-generated main method to display this
* org.eclipse.swt.widgets.Composite inside a new Shell.
*/
public static void main(String[] args) {
showGUI();
}
/**
* Overriding checkSubclass allows this class to extend org.eclipse.swt.widgets.Composite
*/
protected void checkSubclass() {
}
/**
* Auto-generated method to display this
* org.eclipse.swt.widgets.Composite inside a new Shell.
*/
public static void showGUI() {
Display display = Display.getDefault();
Shell shell = new Shell(display);
ScrolledCompTest inst = new ScrolledCompTest(shell, SWT.NULL);
Point size = inst.getSize();
shell.setLayout(new FillLayout());
shell.layout();
if(size.x == 0 && size.y == 0) {
inst.pack();
shell.pack();
} else {
Rectangle shellBounds = shell.computeTrim(0, 0, size.x, size.y);
shell.setSize(shellBounds.width, shellBounds.height);
}
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
public ScrolledCompTest(org.eclipse.swt.widgets.Composite parent, int style) {
super(parent, style);
initGUI();
}
private void initGUI() {
try {
FillLayout thisLayout = new FillLayout();
this.setLayout(thisLayout);
this.layout();
final ScrolledComposite scrollComposite = new ScrolledComposite(this, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
final Composite comp = new Composite(scrollComposite, SWT.NONE);
GridLayout compLyt = new GridLayout(2, false);
comp.setLayout(compLyt);
Label l = new Label(comp, SWT.BORDER);
l.setText("this is sample lable");
GridData lData = new GridData();
lData.widthHint = 200;
l.setLayoutData(lData);
Text t = new Text(comp, SWT.BORDER);
t.setText("hello");
GridData tData = new GridData();
tData.widthHint = 100;
t.setLayoutData(tData);
scrollComposite.setContent(comp);
scrollComposite.setExpandVertical(true);
scrollComposite.setExpandHorizontal(true);
scrollComposite.setMinSize(comp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
} catch (Exception e) {
e.printStackTrace();
}
}
}
Anyways thanks to all the guys...who atleast gave a try on this.....
cheers ,
|
|
|
Goto Forum:
Current Time: Tue Apr 23 06:03:55 GMT 2024
Powered by FUDForum. Page generated in 0.04426 seconds
|