Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Dynamically change the parent without disposing the children
Dynamically change the parent without disposing the children [message #888724] Mon, 18 June 2012 14:46 Go to next message
nani Missing name is currently offline nani Missing nameFriend
Messages: 10
Registered: May 2011
Junior Member
Hi,

I got a situation where i need to create Labels[children] on Composite[parent].i am creating using the following code

for(wordnum = 0;wordnum<256;wordnum++)
{
word[wordnum] = new Label(composite, SWT.BORDER);
word[wordnum].setToolTipText(Integer.valueOf(wordnum+1).toString());
word[wordnum].setData(Integer.valueOf(wordnum+1).toString());
word[wordnum].setText(Integer.valueOf(wordnum+1).toString());
}


the layout for this composite is GridLayout.

when i select a value from combo box which is present in my UI.the labels should be ordered differently

Example: If the UI before selecting the option in combo box is

1 65 129 193 17 81 145 209 33 97 161 225 49 113 177 241
2 66 130 194 18 82 146 210 34 98 162 226 50 114 178 242


After selecting the value from combo box the UI should be

1 33 65 97 129 161 193 225 17 49 81 113 145 177 209 241
2 34 66 98 130 162 194 226 18 50 82 114 146 178 210 242


I am using the GridLayout ,here the problem is when i change the columns the values are displaying in a wrong way like this.

1 65 129 193 2 66 130 194 17 81 145 209 18 82 146 210
Please suggest me some solution.

Thanks in advance.
Re: Dynamically change the parent without disposing the children [message #889485 is a reply to message #888724] Tue, 19 June 2012 09:24 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Hi, why you can't recreate all those Labels whenever the selection in the combo changes?
Re: Dynamically change the parent without disposing the children [message #889799 is a reply to message #889485] Tue, 19 June 2012 16:56 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
If your case is really just a bunch of labels then it's most efficient
to setText() on each of them with their new content and then
parent.layout(true).

To re-arrange controls that have a common parent use Control.moveAbove()
repeatedly, and when you're done parent.layout(true).

Grant


On 6/19/2012 5:24 AM, Jan Krakora wrote:
> Hi, why you can't recreate all those Labels whenever the selection in
> the combo changes?
Re: Dynamically change the parent without disposing the children [message #890094 is a reply to message #889799] Thu, 21 June 2012 05:23 Go to previous message
nani Missing name is currently offline nani Missing nameFriend
Messages: 10
Registered: May 2011
Junior Member
@jan Krakora ,
I am assigning TONS of data to each label before positioning , if i recreate the labels i have to reload the data and set that again,which might decrease my tool performance.


Thanks for the reply..

@Grant Gayed ,

I am iterating and setting the bounds for each label which solved my problem,but i am unable to stop the scroll bar,because i am using a composite over a scrolled composite and i am setting the size of composite dynamically.how can i restrict the scroll bar when the user can see all labels.

Thanks for the reply...
Previous Topic:Page Settings in Visio through SWT
Next Topic:Aligment in a TableViewer
Goto Forum:
  


Current Time: Fri Apr 19 21:48:47 GMT 2024

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

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

Back to the top