Components and Layouts tricks

Hello

I am trying to achieve a way of doing something and I am limited with knowledge of the toolkit…i tried to read through forum but i could not find a suitable topic for my question…

selectNewEventType.addItem("Create New Event");
selectNewEventType.addItem("Modify Existing Event");

i have added those two items to select and then I add the whole select to a panel.
Depending on the user action, i have to load a Layout in the panel, now a user can select choose the first action then i have to load a layout for creating a new event, and then a user can decide to load a second Layout for modifying the event :: that means i have to remove the previous panel and load another panel…
the catch is : how can i know if a layout is existing in the panel?
Because if i know a panel is existing then i can easily remove it…
or how can i test if the Panel or Layout has a particular component?

at the moment i am doing this


try {
calenderEventPanel.removeComponent(calenderEventLayout);
} catch (Exception e) {	}

i am not happy because i am logging my errors and its not fun to look at the error which are being thrown by this…

thanks in advance for the help

I didn’t get the whole thing but

You can do a check


if(calendarEventLayout.getParent()==calendarEventPanel){
  calenderEventPanel.removeComponent(calenderEventLayout);
}

getParent gives the next layer upwards, where the component is in, or null if it isn’t added anywhere

Thanks now works :slight_smile: