Saturday, October 6, 2012

Eclipse PDE - While creating XWT component and adding to Palette, End user sees the component twice when dragged and dropped

You create an XWT composite component, say button and name it as 'MyButton', then the wizard creates 2 files for you. One is MyButton.xwt and other one MyButton.java.
You will add the new component into palette by normal 'add component' wizard and it is ready for end user to be dragged and dropped.

But when an user drags and drops the 'MyButton' component from palette, it appears twice on UI.

Reason: Actually the two fies '.xwt' and '.java', both files would have the initialization routine by default. so when 'MyButton' component was dropped, both of them initialized and showed twice. Ideally '.java' file should be used as a handler to handle the events from UI. So To solve it, delete the initialization routine written inside the constructor of 'MyButton.java' file. That should fix this problem.
Another reason that might contribute to the double appearance is name of a property matching to parent class. Suppose inside MyButton.java file, you declare a property called 'size' and write getter/setter for this. Purpose of such property is to customize 'size' property and show 'size' property whenever user clicks on 'MyButton' component. BUT originally there is already a 'size' property in parent class...so when you write 'size' and build your component, It will show up twice when user drops the component from palette. You can rename your 'size' property to any other string...And that should fix this problem too. 

1 comment:

Anonymous said...

It is cheapеr аnԁ morе sеnsіble, аnd
uѕuаlly includеs regular visits to thе doctor for routine check-ups.
When shopping foг health insurancе, it may bе bеnеficial to сonsiԁег the best οf the bеѕt.
Many insuгance plans allοω you to have a few weeks tο
tеst out a policy.

My web blog - Averаge Ϲost Of Private Health Insurance Uk (Http://Www.Tarr.Pl)