Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » XWT: Preview & Run-time views are different
XWT: Preview & Run-time views are different [message #571697] Thu, 25 March 2010 05:25 Go to next message
can kayacan is currently offline can kayacanFriend
Messages: 16
Registered: March 2010
Junior Member
Hi,

I have simple UI element, which has two button and a text widgets. The XWT designer and the Preview shows the button and text size (width and height) as I expected. But the run-time widget sizes are not shown as I defined. The default widget size is being shown.

Anyone has any idea, what is the correct way to define the widget width and height?

Demo.xwt
<Composite xmlns="http://www.eclipse.org/xwt/presentation"
xmlns:x="http://www.eclipse.org/xwt" xmlns:c="clr-namespace:demo.xwt"
xmlns:j="clr-namespace:java.lang" x:Class="demo.xwt.Demo">

<Composite.layout>
<GridLayout numColumns="2" />
</Composite.layout>

<Text x:style="SWT.NONE" weight="400" height="150" />

<Button x:style="SWT.PUSH" x:Name="NotifyButton1" text="Notify" width="200" Height="50" />

<Button x:style="SWT.PUSH" x:Name="NotifyButton2" text="Notify" width="200" Height="50" />

</Composite>


Demo.java
public class Demo extends Composite {

public Demo(Composite parent, int style) {
super(parent, style);
}

}



Simple main method:
public static void main(String[] args) {
URL content = Demo.class.getResource("Demo.xwt");
try {
XWT.open(content);
} catch (Exception e) {
e.printStackTrace();
}
}
Re: XWT: Preview & Run-time views are different [message #571767 is a reply to message #571697] Thu, 25 March 2010 11:56 Go to previous messageGo to next message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
You should use GridData for GridLayout instead of specifying size directly.
In general Layout manages location and size, so your width/height are overridden.

You want something like this
<Composite xmlns="http://www.eclipse.org/xwt/presentation" xmlns:x="http://www.eclipse.org/xwt">
<Composite.layout>
<GridLayout numColumns="1"/>
</Composite.layout>
<Text x:Style="BORDER">
<Text.layoutData>
<GridData grabExcessHorizontalSpace="true" horizontalAlignment="FILL" heightHint="150"/>
</Text.layoutData>
</Text>
<Button x:Name="NotifyButton1" text="Notify">
<Button.layoutData>
<GridData widthHint="200" heightHint="50"/>
</Button.layoutData>
</Button>
<Button x:Name="NotifyButton2" text="Notify">
<Button.layoutData>
<GridData heightHint="50" widthHint="200"/>
</Button.layoutData>
</Button>
</Composite>


--
Konstantin Scheglov,
Instantiations, Inc.


Konstantin Scheglov,
Google, Inc.
Re: XWT: Preview & Run-time views are different [message #571876 is a reply to message #571767] Thu, 25 March 2010 20:21 Go to previous messageGo to next message
can kayacan is currently offline can kayacanFriend
Messages: 16
Registered: March 2010
Junior Member
Thank you so much again, Konstantin. This was very helpful.
Re: Preview & Run-time views are different [message #573427 is a reply to message #571697] Thu, 08 April 2010 07:16 Go to previous message
Yves YANG is currently offline Yves YANGFriend
Messages: 688
Registered: July 2009
Senior Member
How do you set the width and height, via XWT Visual Designer? If so, it
could be a bug of the tool and please report a bug.

Regards
Yves
"can kayacan" <kayacanc@hotmail.com> wrote in message
news:hoes53$hh2$1@build.eclipse.org...
> Hi,
>
> I have simple UI element, which has two button and a text widgets. The XWT
> designer and the Preview shows the button and text size (width and
> height) as I expected. But the run-time widget sizes are not shown as I
> defined. The default widget size is being shown.
>
> Anyone has any idea, what is the correct way to define the widget width
> and height?
>
> Demo.xwt
> <Composite xmlns="http://www.eclipse.org/xwt/presentation"
> xmlns:x="http://www.eclipse.org/xwt" xmlns:c="clr-namespace:demo.xwt"
> xmlns:j="clr-namespace:java.lang" x:Class="demo.xwt.Demo">
>
> <Composite.layout>
> <GridLayout numColumns="2" />
> </Composite.layout>
>
> <Text x:style="SWT.NONE" weight="400" height="150" />
>
> <Button x:style="SWT.PUSH" x:Name="NotifyButton1" text="Notify"
> width="200" Height="50" />
>
> <Button x:style="SWT.PUSH" x:Name="NotifyButton2" text="Notify"
> width="200" Height="50" />
>
> </Composite>
>
>
> Demo.java
> public class Demo extends Composite {
> public Demo(Composite parent, int style) {
> super(parent, style);
> }
>
> }
>
>
>
> Simple main method: public static void main(String[] args) {
> URL content = Demo.class.getResource("Demo.xwt");
> try {
> XWT.open(content);
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
Previous Topic:Form support in XWT Designer
Next Topic:XWT: Preview & Run-time views are different
Goto Forum:
  


Current Time: Thu Apr 25 14:58:39 GMT 2024

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

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

Back to the top