Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » JFace Dialog Sizing and Form Layout
JFace Dialog Sizing and Form Layout [message #450351] Thu, 10 February 2005 18:33 Go to next message
Mark Victory is currently offline Mark VictoryFriend
Messages: 133
Registered: July 2009
Senior Member
Hi All,

I am trying to get a JFace dialog to behave correctly but must be doing
something wrong.

In the createDialogArea method below, I try to set the initial size and
location of my dialog.
However this appears to have no effect. Rather, the size seems to be
dependent on the FormData settings that I use when I create the widgets in
the dialog.

Am I doing something wrong or is this functionality just flaky in
JFace/SWT/FormLayout?

Thanks,
Mark

protected Control createDialogArea(Composite parent)
{
FormData formData;
FormData formData2;
Composite area = (Composite) super.createDialogArea(parent);
area.setBounds(100,100,500,500);
FormLayout layout = new FormLayout();
layout.marginHeight = 3;
layout.marginWidth = 3;
area.setLayout(layout);
{
m_text = new Text(area, SWT.BORDER|SWT.MULTI|SWT.WRAP|SWT.V_SCROLL);
formData2 = new FormData();
formData2.top = new FormAttachment(0, 5);
formData2.bottom = new FormAttachment(90, -5);
formData2.left = new FormAttachment(0, 5);
formData2.right = new FormAttachment(100, -5);
m_text.setLayoutData(formData2);
}
{
m_applyButton = new Button(area, SWT.PUSH);
formData = new FormData();
formData.top = new FormAttachment(m_text, 5);
formData.left = new FormAttachment(0, 5);
m_applyButton.setLayoutData(formData);
m_applyButton.setText("Apply Comments");
}
return area;
}
Re: JFace Dialog Sizing and Form Layout [message #450419 is a reply to message #450351] Fri, 11 February 2005 16:13 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
To understand what SWT is doing, create a stand alone SWT example that uses
FormLayout. That will help you determine who is causing the trouble.

"Mark Victory" <MVictory@us.ibm.com> wrote in message
news:cug964$3c5$1@www.eclipse.org...
> Hi All,
>
> I am trying to get a JFace dialog to behave correctly but must be doing
> something wrong.
>
> In the createDialogArea method below, I try to set the initial size and
> location of my dialog.
> However this appears to have no effect. Rather, the size seems to be
> dependent on the FormData settings that I use when I create the widgets in
> the dialog.
>
> Am I doing something wrong or is this functionality just flaky in
> JFace/SWT/FormLayout?
>
> Thanks,
> Mark
>
> protected Control createDialogArea(Composite parent)
> {
> FormData formData;
> FormData formData2;
> Composite area = (Composite) super.createDialogArea(parent);
> area.setBounds(100,100,500,500);
> FormLayout layout = new FormLayout();
> layout.marginHeight = 3;
> layout.marginWidth = 3;
> area.setLayout(layout);
> {
> m_text = new Text(area,
SWT.BORDER|SWT.MULTI|SWT.WRAP|SWT.V_SCROLL);
> formData2 = new FormData();
> formData2.top = new FormAttachment(0, 5);
> formData2.bottom = new FormAttachment(90, -5);
> formData2.left = new FormAttachment(0, 5);
> formData2.right = new FormAttachment(100, -5);
> m_text.setLayoutData(formData2);
> }
> {
> m_applyButton = new Button(area, SWT.PUSH);
> formData = new FormData();
> formData.top = new FormAttachment(m_text, 5);
> formData.left = new FormAttachment(0, 5);
> m_applyButton.setLayoutData(formData);
> m_applyButton.setText("Apply Comments");
> }
> return area;
> }
>
>
Re: JFace Dialog Sizing and Form Layout [message #450440 is a reply to message #450351] Fri, 11 February 2005 22:43 Go to previous message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
It is not clear from your code. Is area a Shell? If not, area is probably
being managed by a layout in parent and setting the bounds will have no
effect because the layout on parent will override your setBounds.

If you are trying to set the position of teh dialog on teh screen, you could
do something like this:

area.getShell().setBounds(100, 100, 500, 500);

Be careful about positioning a dialog. Some people have multiple monitors
and this code may put the dialog in a bizarre location. For more info about
working with multiple monitors, see:

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet120.java?rev=HEAD& amp;content-type=text/vnd.viewcvs-markup


"Mark Victory" <MVictory@us.ibm.com> wrote in message
news:cug964$3c5$1@www.eclipse.org...
> Hi All,
>
> I am trying to get a JFace dialog to behave correctly but must be doing
> something wrong.
>
> In the createDialogArea method below, I try to set the initial size and
> location of my dialog.
> However this appears to have no effect. Rather, the size seems to be
> dependent on the FormData settings that I use when I create the widgets in
> the dialog.
>
> Am I doing something wrong or is this functionality just flaky in
> JFace/SWT/FormLayout?
>
> Thanks,
> Mark
>
> protected Control createDialogArea(Composite parent)
> {
> FormData formData;
> FormData formData2;
> Composite area = (Composite) super.createDialogArea(parent);
> area.setBounds(100,100,500,500);
> FormLayout layout = new FormLayout();
> layout.marginHeight = 3;
> layout.marginWidth = 3;
> area.setLayout(layout);
> {
> m_text = new Text(area,
> SWT.BORDER|SWT.MULTI|SWT.WRAP|SWT.V_SCROLL);
> formData2 = new FormData();
> formData2.top = new FormAttachment(0, 5);
> formData2.bottom = new FormAttachment(90, -5);
> formData2.left = new FormAttachment(0, 5);
> formData2.right = new FormAttachment(100, -5);
> m_text.setLayoutData(formData2);
> }
> {
> m_applyButton = new Button(area, SWT.PUSH);
> formData = new FormData();
> formData.top = new FormAttachment(m_text, 5);
> formData.left = new FormAttachment(0, 5);
> m_applyButton.setLayoutData(formData);
> m_applyButton.setText("Apply Comments");
> }
> return area;
> }
>
>
Previous Topic:Listening for Property Changes
Next Topic:How to convert a java String into a pointer
Goto Forum:
  


Current Time: Thu Apr 25 06:00:03 GMT 2024

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

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

Back to the top